table calendar pretty much does what cal(1) does - prints out a calendar.
It has some other options, and when I've gotten a better idea of the php
OO syntax, I'll make this into a class that can be accessed more convenienty.
I'm currently using this in a system that has no graphics, but I want hooks
to make graphics available for element of the table, with an ALT tag for
text browsers. have fun, send suggestions, questions, etc to spacey@pobox.com
<!-- I should add something in here to highlight "today" if it's in the scope of the viewed month -->
<!-- -PN 3/30/1998 -->
<?
# $selected{Month,Day,Year} should be set by the calling script.
# Actually, I should turn this into a function/object, and call it with
# those values. That would sanatize the calling script. Too many
# variables crawling about already.
# Create an html calendar for a month.
if (!$selectedDay ) {
$selectedDay = date( 'd');
}
if (!$selectedMonth) {
$selectedMonth = date( 'm');
}
if (!$selectedYear) {
$selectedYear = date( 'Y');
}
# get the first day of the week!
$firstday = date( 'w',mktime(0,0,0,$selectedMonth,1,$selectedYear));
# have to perform a loop to test from 31 backwards using this
# to see which is the last day of the month
$lastday = 31;
do {
# *Sigh* recursion would have been more fun here.
$monthOrig = date( 'm',mktime(0,0,0,$selectedMonth,1,$selectedYear));
$monthTest = date( 'm',mktime(0,0,0,$selectedMonth,$lastday,$selectedYear));
if ($monthTest != $monthOrig) { $lastday -= 1; }
} while ($monthTest != $monthOrig);
if($DEBUGGING_SET) {
print( "<p>first day of the first week of $selectedMonth $selectedYear is $firstday (from 0 to 6) <p>\n");
print( "The last day of $selectedMonth $selectedYear is $lastday\n<p>");
}