$m = (!$m) ? date("m",mktime()) : "$m";
$y = (!$y) ? date("Y",mktime()) : "$y";
if ($REQUEST_METHOD == "POST")
{
print "
Form Submitted.
";
print "...you really should do something with this data...
";
print "Event: $event
";
print "Date: $eventdate
";
exit();
}
?>
Date Menu: Add New Event
Calendar Select
|
|
mk_drawCalendar($m,$y); ?>
|
//*********************************************************
// DRAW CALENDAR
//*********************************************************
/*
Draws out a calendar (in html) of the month/year
passed to it date passed in format mm-dd-yyyy
*/
function mk_drawCalendar($m,$y)
{
if ((!$m) || (!$y))
{
$m = date("m",mktime());
$y = date("Y",mktime());
}
/*== get what weekday the first is on ==*/
$tmpd = getdate(mktime(0,0,0,$m,1,$y));
$month = $tmpd["month"];
$firstwday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($m,$y);
?>
|
Su | M |
T | W |
Th | F |
Sa |
$d = 1;
$wday = $firstwday;
$firstweek = true;
/*== loop through all the days of the month ==*/
while ( $d <= $lastday)
{
/*== set up blank days for first week ==*/
if ($firstweek) {
print "";
for ($i=1; $i<=$firstwday; $i++)
{ print " | "; }
$firstweek = false;
}
/*== Sunday start week with
==*/
if ($wday==0) { print "
"; }
/*== check for event ==*/
print "";
print "$d";
print " | \n";
/*== Saturday end week with
==*/
if ($wday==6) { print "\n"; }
$wday++;
$wday = $wday % 7;
$d++;
}
?>
Click on date above to select
/*== end drawCalendar function ==*/
}
/*== get the last day of the month ==*/
function mk_getLastDayofMonth($mon,$year)
{
for ($tday=28; $tday <= 31; $tday++)
{
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon)
{ break; }
}
$tday--;
return $tday;
}
?>