11 Replies - 1525 Views - Last Post: 19 August 2010 - 07:52 PM Rate Topic: -----

#1 Guest_newcoder*


Reputation:

CALENDAR

Posted 18 August 2010 - 07:53 PM

Good day!

i download a sample calendar and i want to change something in the calendar like the day because in the calendar that i download its start on sunday, i want it to start on monday,,I don't know how can i do it..

here is the code:
<?php

	$host = "localhost";

	$username = "";

	$password = "";

	$dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database');

	$dbName = '';

	mysql_select_db($dbName);	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<script>

function goLastMonth(month, year){

	// If the month is January, decrement the year

	if(month == 1){

		--year;

		month = 13;

	}

	document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;

}

//next function

function goNextMonth(month, year){

	// If the month is December, increment the year

	if(month == 12){

	++year;

	month = 0;

	}

	document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;

}  



function remChars(txtControl, txtCount, intMaxLength)

{

if(txtControl.value.length > intMaxLength)

	txtControl.value = txtControl.value.substring(0, (intMaxLength-1));

else

	txtCount.value = intMaxLength - txtControl.value.length;

}



function checkFilled() {

var filled = 0

var x = document.form1.calName.value;

//x = x.replace(/^\s+/,"");  // strip leading spaces

if (x.length > 0) {filled ++}



var y = document.form1.calDesc.value;

//y = y.replace(/^s+/,"");  // strip leading spaces

if (y.length > 0) {filled ++}



if (filled == 2) {

document.getElementById("Submit").disabled = false;

}

else {document.getElementById("Submit").disabled = true}  // in case a field is filled then erased



}



</script>

<style>

body{

	font-family:Georgia, "Times New Roman", Times, serif;

	font-size:12px;

}

.today{

	/*background-color:#00CCCC;*/

	font-weight:bold;

	background-image:url(calBg.jpg);

	background-repeat:no-repeat;

	background-position:center;

	position:relative;

}

.today span{

	position:absolute;

	left:0;

	top:0;	

}



.today a{

	color:#000000;

	padding-top:10px;

}

.selected {

color: #FFFFFF;

background-color: #C00000;

}

.event {

	background-color: #C6D1DC;

	border:1px solid #ffffff;

} 

.normal {



} 

table{

	border:1px solid #cccccc;

	padding:3px;

}

th{

	width:36px;

	background-color:#cccccc;

	text-align:center;

	color:#ffffff;

	border-left:1px solid #ffffff;

}

td{

	text-align:center;

	padding:10px;

	margin:0;

}

table.tableClass{

	width:350px;

	border:none;

	border-collapse: collapse;

	font-size:85%;

	border:1px dotted #cccccc;

}

table.tableClass input,textarea{

	font-size:90%;

}

#form1{

	margin:5px 0 0 0;

}

#greyBox{

	height:10px;

	width:10px;

	background-color:#C6D1DC;

	border:1px solid #666666;

	margin:5px;

}

#legend{

	margin:5 0 10px 50px;

	width:200px;

}

#hr{border-bottom:1px solid #cccccc;width:300px;}

.output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;}

h5{margin:0;}

</style>

</head>



<body>

<div id="legend"> 

<img src="sq.jpg" /> Scheduled Events<br/><img src="calBg.jpg" height="10"/> Todays Date</div>

<?php

	//$todaysDate = date("n/j/Y");

	//echo $todaysDate;

	// Get values from query string

	$day = (isset($_GET["day"])) ? $_GET['day'] : "";

	$month = (isset($_GET["month"])) ? $_GET['month'] : "";

	$year = (isset($_GET["year"])) ? $_GET['year'] : "";

	//comparaters for today's date

	//$todaysDate = date("n/j/Y");

	//$sel = (isset($_GET["sel"])) ? $_GET['sel'] : "";

	//$what = (isset($_GET["what"])) ? $_GET['what'] : "";

	

	//$day = (!isset($day)) ? $day = date("j") : $day = "";

	if(empty($day)){ $day = date("j"); }

	

	if(empty($month)){ $month = date("n"); }

	

	if(empty($year)){ $year = date("Y"); } 

	//set up vars for calendar etc

	$currentTimeStamp = strtotime("$year-$month-$day");

	$monthName = date("F", $currentTimeStamp);

	$numDays = date("t", $currentTimeStamp);

	$counter = 0;

	//$numEventsThisMonth = 0;

	//$hasEvent = false;

	//$todaysEvents = ""; 

	//run a selec statement to hi-light the days

	function hiLightEvt($eMonth,$eDay,$eYear){

		//$tDayName = date("l");

		$todaysDate = date("n/j/Y");

		$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;

		if($todaysDate == $dateToCompare){

			//$aClass = '<span>' . $tDayName . '</span>';

			$aClass='class="today"';

		}else{

			//$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;

			//echo $todaysDate;

			//return;

			$sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";

			//echo $sql;

			//return;

			$result = mysql_query($sql);

			while($row= mysql_fetch_array($result)){

				if($row['eCount'] >=1){

					$aClass = 'class="event"';

				}elseif($row['eCount'] ==0){

					$aClass ='class="normal"';

				}

			}

		}

		return $aClass;

	}

?>

<table width="350" cellpadding="0" cellspacing="0">

<tr>

<td width="50" colspan="1">

<input type="button" value=" < " onclick="goLastMonth(<?php echo $month . ", " . $year; ?>);">

</td>

<td width="250" colspan="5">

<span class="title"><?php echo $monthName . " " . $year; ?></span><br>

</td>

<td width="50" colspan="1" align="right">

<input type="button" value=" > " onclick="goNextMonth(<?php echo $month . ", " . $year; ?>);">

</td>

</tr> 

<tr>

    <th>S</td>

    <th>M</td>

    <th>T</td>

    <th>W</td>

    <th>T</td>

    <th>F</td>

    <th>S</td>

</tr>

<tr>

<?php

	for($i = 1; $i < $numDays+1; $i++, $counter++){

		$dateToCompare = $month . '/' . $i . '/' . $year;

		$timeStamp = strtotime("$year-$month-$i");

		//echo $timeStamp . '<br/>';

		if($i == 1){

			// Workout when the first day of the month is

			$firstDay = date("w", $timeStamp);

			for($j = 0; $j < $firstDay; $j++, $counter++){

				echo "<td>&nbsp;</td>";

			} 

		}

		if($counter % 7 == 0){

		?>

			</tr><tr>

        <?php

		}

		?>

        <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 

    <?php

	}

?>

</table>

<?php

if(isset($_GET['v'])){

	if(isset($_POST['Submit'])){

		$sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";

		mysql_query($sql);

	}

$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";

//echo $sql;

//return;

$result = mysql_query($sql);

$numRows = mysql_num_rows($result);

?>

<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Event</a><br/>

<?php

if(isset($_GET['f'])){

		include 'calForm.php';

}

if($numRows == 0 ){

	echo '<h3>No Events</h3>';

}else{

//echo '<ul>';

echo '<h3>Events Listed</h3>';

	while($row = mysql_fetch_array($result)){

?>

	<div class="output">

		<h5><?=$row['calName'];?></h5>

    	<?=$row['calDesc'];?><br/>

    	Listed On: <?=$row['calStamp'];?>

    </div>

<?php

	}

  }

}

?>

</body>

</body>

</html>




Is This A Good Question/Topic? 0

Replies To: CALENDAR

#2 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: CALENDAR

Posted 18 August 2010 - 08:02 PM

View Postnewcoder, on 19 August 2010 - 01:53 AM, said:

Good day!

i download a sample calendar and i want to change something in the calendar like the day because in the calendar that i download its start on sunday, i want it to start on monday,,I don't know how can i do it..


Thats why you shouldn't copy paste code blindly. So what did you try ? what code lines do you think you should modify to get the answer ?
Was This Post Helpful? 0
  • +
  • -

#3 Guest_newcoder*


Reputation:

Re: CALENDAR

Posted 19 August 2010 - 12:53 AM

Good Day...


I research about the code for calendar and sad to say all of them the day start on sunday...I want that the day satrt on monday...

Who are know the code for the calendar that start the day on Monday...


Please Help me...


i try to edit the code i research but nothings has change....


Thank you
Was This Post Helpful? 0

#4 Guest_newcoder*


Reputation:

Re: CALENDAR

Posted 19 August 2010 - 12:54 AM

Good Day...


I research about the code for calendar and sad to say all of them the day start on sunday...I want that the day satrt on monday...

Who are know the code for the calendar that start the day on Monday...


Please Help me...


i try to edit the code i research but nothings has change....


Thank you
Was This Post Helpful? 0

#5 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: CALENDAR

Posted 19 August 2010 - 12:57 AM

Identical posts

http://www.dreaminco...e-for-calendar/
Was This Post Helpful? 0
  • +
  • -

#6 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: CALENDAR

Posted 19 August 2010 - 01:01 AM

View PostCrunch, on 19 August 2010 - 08:57 AM, said:


Crunch, you can report posts or topics in the Report a Post/Topic forum.

But for this case I already did it.
Was This Post Helpful? 0
  • +
  • -

#7 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: CALENDAR

Posted 19 August 2010 - 01:04 AM

Oh Sorry. :sad3:
Was This Post Helpful? 0
  • +
  • -

#8 guahguahmonster  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 209
  • Joined: 29-August 07

Re: CALENDAR

Posted 19 August 2010 - 02:48 AM

newcoder, where is "the code" you speak of? How can we possibly know what to change to get the calendar to start on a different day of the week unless we can see the code?
Was This Post Helpful? 0
  • +
  • -

#9 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 103
  • Joined: 29-July 09

Re: CALENDAR

Posted 19 August 2010 - 03:11 AM

We need to see some coding you have already got. We cant just give you coding, You have got to show us your are trying.
Was This Post Helpful? 0
  • +
  • -

#10 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: CALENDAR

Posted 19 August 2010 - 04:27 AM

Merged duplicate topics. Please do NOT create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

#11 Guest_newcoder*


Reputation:

Re: CALENDAR

Posted 19 August 2010 - 05:04 PM

View Postguahguahmonster, on 19 August 2010 - 01:48 AM, said:

newcoder, where is "the code" you speak of? How can we possibly know what to change to get the calendar to start on a different day of the week unless we can see the code?



Here is the code:

<?php

	$host = "localhost";

	$username = "";

	$password = "";

	$dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database');

	$dbName = '';

	mysql_select_db($dbName);	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<script>

function goLastMonth(month, year){

	// If the month is January, decrement the year

	if(month == 1){

		--year;

		month = 13;

	}

	document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;

}

//next function

function goNextMonth(month, year){

	// If the month is December, increment the year

	if(month == 12){

	++year;

	month = 0;

	}

	document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;

}  



function remChars(txtControl, txtCount, intMaxLength)

{

if(txtControl.value.length > intMaxLength)

	txtControl.value = txtControl.value.substring(0, (intMaxLength-1));

else

	txtCount.value = intMaxLength - txtControl.value.length;

}



function checkFilled() {

var filled = 0

var x = document.form1.calName.value;

//x = x.replace(/^\s+/,"");  // strip leading spaces

if (x.length > 0) {filled ++}



var y = document.form1.calDesc.value;

//y = y.replace(/^s+/,"");  // strip leading spaces

if (y.length > 0) {filled ++}



if (filled == 2) {

document.getElementById("Submit").disabled = false;

}

else {document.getElementById("Submit").disabled = true}  // in case a field is filled then erased



}



</script>

<style>

body{

	font-family:Georgia, "Times New Roman", Times, serif;

	font-size:12px;

}

.today{

	/*background-color:#00CCCC;*/

	font-weight:bold;

	background-image:url(calBg.jpg);

	background-repeat:no-repeat;

	background-position:center;

	position:relative;

}

.today span{

	position:absolute;

	left:0;

	top:0;	

}



.today a{

	color:#000000;

	padding-top:10px;

}

.selected {

color: #FFFFFF;

background-color: #C00000;

}

.event {

	background-color: #C6D1DC;

	border:1px solid #ffffff;

} 

.normal {



} 

table{

	border:1px solid #cccccc;

	padding:3px;

}

th{

	width:36px;

	background-color:#cccccc;

	text-align:center;

	color:#ffffff;

	border-left:1px solid #ffffff;

}

td{

	text-align:center;

	padding:10px;

	margin:0;

}

table.tableClass{

	width:350px;

	border:none;

	border-collapse: collapse;

	font-size:85%;

	border:1px dotted #cccccc;

}

table.tableClass input,textarea{

	font-size:90%;

}

#form1{

	margin:5px 0 0 0;

}

#greyBox{

	height:10px;

	width:10px;

	background-color:#C6D1DC;

	border:1px solid #666666;

	margin:5px;

}

#legend{

	margin:5 0 10px 50px;

	width:200px;

}

#hr{border-bottom:1px solid #cccccc;width:300px;}

.output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;}

h5{margin:0;}

</style>

</head>



<body>

<div id="legend"> 

<img src="sq.jpg" /> Scheduled Events<br/><img src="calBg.jpg" height="10"/> Todays Date</div>

<?php

	//$todaysDate = date("n/j/Y");

	//echo $todaysDate;

	// Get values from query string

	$day = (isset($_GET["day"])) ? $_GET['day'] : "";

	$month = (isset($_GET["month"])) ? $_GET['month'] : "";

	$year = (isset($_GET["year"])) ? $_GET['year'] : "";

	//comparaters for today's date

	//$todaysDate = date("n/j/Y");

	//$sel = (isset($_GET["sel"])) ? $_GET['sel'] : "";

	//$what = (isset($_GET["what"])) ? $_GET['what'] : "";

	

	//$day = (!isset($day)) ? $day = date("j") : $day = "";

	if(empty($day)){ $day = date("j"); }

	

	if(empty($month)){ $month = date("n"); }

	

	if(empty($year)){ $year = date("Y"); } 

	//set up vars for calendar etc

	$currentTimeStamp = strtotime("$year-$month-$day");

	$monthName = date("F", $currentTimeStamp);

	$numDays = date("t", $currentTimeStamp);

	$counter = 0;

	//$numEventsThisMonth = 0;

	//$hasEvent = false;

	//$todaysEvents = ""; 

	//run a selec statement to hi-light the days

	function hiLightEvt($eMonth,$eDay,$eYear){

		//$tDayName = date("l");

		$todaysDate = date("n/j/Y");

		$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;

		if($todaysDate == $dateToCompare){

			//$aClass = '<span>' . $tDayName . '</span>';

			$aClass='class="today"';

		}else{

			//$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;

			//echo $todaysDate;

			//return;

			$sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";

			//echo $sql;

			//return;

			$result = mysql_query($sql);

			while($row= mysql_fetch_array($result)){

				if($row['eCount'] >=1){

					$aClass = 'class="event"';

				}elseif($row['eCount'] ==0){

					$aClass ='class="normal"';

				}

			}

		}

		return $aClass;

	}

?>

<table width="350" cellpadding="0" cellspacing="0">

<tr>

<td width="50" colspan="1">

<input type="button" value=" < " onclick="goLastMonth(<?php echo $month . ", " . $year; ?>);">

</td>

<td width="250" colspan="5">

<span class="title"><?php echo $monthName . " " . $year; ?></span><br>

</td>

<td width="50" colspan="1" align="right">

<input type="button" value=" > " onclick="goNextMonth(<?php echo $month . ", " . $year; ?>);">

</td>

</tr> 

<tr>

    <th>S</td>

    <th>M</td>

    <th>T</td>

    <th>W</td>

    <th>T</td>

    <th>F</td>

    <th>S</td>

</tr>

<tr>

<?php

	for($i = 1; $i < $numDays+1; $i++, $counter++){

		$dateToCompare = $month . '/' . $i . '/' . $year;

		$timeStamp = strtotime("$year-$month-$i");

		//echo $timeStamp . '<br/>';

		if($i == 1){

			// Workout when the first day of the month is

			$firstDay = date("w", $timeStamp);

			for($j = 0; $j < $firstDay; $j++, $counter++){

				echo "<td>&nbsp;</td>";

			} 

		}

		if($counter % 7 == 0){

		?>

			</tr><tr>

        <?php

		}

		?>

        <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 

    <?php

	}

?>

</table>

<?php

if(isset($_GET['v'])){

	if(isset($_POST['Submit'])){

		$sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";

		mysql_query($sql);

	}

$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";

//echo $sql;

//return;

$result = mysql_query($sql);

$numRows = mysql_num_rows($result);

?>

<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Event</a><br/>

<?php

if(isset($_GET['f'])){

		include 'calForm.php';

}

if($numRows == 0 ){

	echo '<h3>No Events</h3>';

}else{

//echo '<ul>';

echo '<h3>Events Listed</h3>';

	while($row = mysql_fetch_array($result)){

?>

	<div class="output">

		<h5><?=$row['calName'];?></h5>

    	<?=$row['calDesc'];?><br/>

    	Listed On: <?=$row['calStamp'];?>

    </div>

<?php

	}

  }

}

?>

</body>

</body>

</html>



I try to edit the code but the result i want was not happen...I'm not too good in logic of the program so that i feel difficulty in analyzing program...

I hope you can help me....
Was This Post Helpful? 0

#12 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2993
  • View blog
  • Posts: 10,342
  • Joined: 08-August 08

Re: CALENDAR

Posted 19 August 2010 - 07:52 PM

Because this isn't your code and your intention doesn't seem to be to learn how to write code I'm thinking that you really should be posting in the "Post a Job" section.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1