PHP simple calendar script. Please try and use on your web site.
The following PHP script code:
This calendar is not very pretty as-is, but it is functional and fast.
Formatting to suit your needs should be fairly simple.
The latest version of this calendar is formatted much more nice ley. It
also includes a full-featured "Community Calendar" which is linked to a
MySQL database for reporting upcoming events.
The latest copy of the calendar can be viewed and/or downloaded from:
http://modems.rosenet.net/mysql/ */
http://modems.rosenet.net/mysql/ */
/* Set some variables */
$date=01;
$day=01;
$off=0;
$date=01;
$day=01;
$off=0;
/* The month and year variables can (should) be passed from a preceding
web page rather than hard coded */
$month = '05';
$year = '1999';
web page rather than hard coded */
$month = '05';
$year = '1999';
/* Figure out how many days are in this month */
while (checkdate($month,$date,$year)):
$date++;
endwhile;
while (checkdate($month,$date,$year)):
$date++;
endwhile;
/* Create a table with days of the week headers */
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
while ($day<$date):
$off = '01';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Monday') {
echo "";
$off= '02';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Tuesday') {
echo "";
$off= '03';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Wednesday') {
echo "";
$off= '04';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Thursday') {
echo "";
$off= '05';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Friday') {
echo "";
$off= '06';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Saturday') {
echo "";
$off= '07';
}
else {
echo "";
}
$off='01';
} else {
echo "";
}
";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
/* Start the table data and make sure the number of days does not exceed
the total for the month - $date will always be one more than the total
number of days in the momth */
echo "
"; the total for the month - $date will always be one more than the total
number of days in the momth */
echo "
while ($day<$date):
/* Figure what day of the week the first falls on and set the number of
preceding and trailing cells accordingly */
if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Sunday') {
echo "
"; preceding and trailing cells accordingly */
if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Sunday') {
echo "
$off = '01';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Monday') {
echo "";
$off= '02';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Tuesday') {
echo "";
$off= '03';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Wednesday') {
echo "";
$off= '04';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Thursday') {
echo "";
$off= '05';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Friday') {
echo "";
$off= '06';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Saturday') {
echo "";
$off= '07';
}
else {
echo "";
}
/* Increment the day and increment the cells that go before the end of the row
and end the row when appropriate */
$day++;
$off++;
and end the row when appropriate */
$day++;
$off++;
if ($off>7) {
echo "
"; echo "
$off='01';
} else {
echo "";
}
endwhile;
echo "
Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$day | $day | $day | $day | $day | $day | $day | $day | |||||||||||||||||||||
?>
0 comments:
Post a Comment