About the demo
|
|||
|
About the demo
The TT calendar library ships with a simple demo script, index.php. This draws a calendar for the current year returned by the host machine with today's date coloured magenta and each day linked such that clicking on a day causes the calendar to be redrawn with that day coloured magenta. Ignoring some code for retrieving variables from the query string, the main body of the demo code is shown below: (some slight edits have been made for display purposes)
<?
# $year is the year supplied in the query string
# $month is the month supplied in the query string
# $day is the day supplied in the query string
include("ttcalendar.php");
$i=1;
for ($disp_month = 1; $disp_month <= 12; $disp_month++) { #step through a year
if($i==1){ echo "<tr>\n";} #start a table row
$month_array = returnmontharray($disp_month, $year); #get the array for this month
#Add links to the days
$month_array = dayrangelink($month_array,"index.php",1,returnmonthlength($disp_month,$year));
$month_array = daycolour($month_array,0,"#dddddd"); #Colour the sundays grey
$month_array = daycolour($month_array,6,"#dddddd"); #Colour the saturdays grey
if($month==$disp_month){ #Make today's date magenta
$month_array = dayrangecolour($month_array,"#ff00ff",$day);
}
#get month name
$monthname_array = getdate(strtotime($year . "-" . $disp_month . "-01"));
echo "<td valign=\"top\" align=\"center\">\n" . $monthname_array["month"] . "\n";
#display the month as HTML
echo returnmonthhtml($month_array,"#ffff00") . "\n</td>\n";
if($i==4){
echo "</tr>\n"; #finish the table row
$i=1;
}
else{
$i++;
}
}
?>
|
|||
|