PDA

View Full Version : [NOT PERTAINING TO VBB] Help with calendar script


Shenlong
16 Jan 2002, 22:14
I wrote a calendar script and I need help, it keeps having an error, try uploading it to a server to see. If not, i will tell u. Baiscally it is ment to have a dropdown to choose the month and the year, when u choose the month the name changes on the top, it doesnt. Also, the start of month day wont change ( a green table is supossed to move when the day changes). Anyway, check it our for yourself:

<?php
$PageTitle = "Celandar";
require ("header.php");
// If the $Month and the $Year values don't exsist, make them the current month and year.
if ((!$Month) && (!$Year)) {
$Month = date ("m");
$Year = date ("Y");
}
// Calculate the viewed Month.
$Timestamp = mktime (0, 0, 0, $Month, 1, $Year);
$MonthName = date("F", $TimeStamp);
// Make a table with the proper month.
print ("<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 ALIGN=CENTER>");
print ("<TR BGCOLOR=BLUE><TD COLSPAN=7 ALIGN=CENTER><FONT COLOR=WHITE><B> $MonthName $Year</B></FONT></TD></TR>");
print ("<TR BGCOLOR=BLUE>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>Su</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>M</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>Tu</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>W</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>Th</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>F</FONT></B></TD>
<TD ALIGN=CENTER WIDTH=20><B>
<FONT COLOR=WHITE>Sa</FONT></B></TD>
</TD>\n");
$MonthStart = date("w", $TimeStamp);
if ($MonthStart == 0) {
$MonthStart = 7;
}
$LastDay = date("d", mktime (0, 0, 0, $Month+1, 0, $Year));
$StartDate = -$MonthStart;
for ($k = 1; $k <= 6; $k++) { // Print 6 rows.
print ("<TR BGCOLOR=WHITE>");
for ($i = 1; $i <= 7; $i++) { // Use 7 columns
$StartDate++;
if (($StartDate <=0) ||
($StartDate > $LastDay)) {
print ("<TD BGCOLOR=GREEN> &nbsp</TD>");
} elseif (($StartDate >= 1) && ($StartDate <=$LastDay)) {
print ("<TD ALIGN=CENTER> $StartDate</TD>");
}
}
print ("</TR>\n");
}
print ("</TABLE>\n");
// Make te form.

print ("<FORM ACTON=\"calendar.php\" METHOD=GET>\n");
print ("Select a new month to view:\n");
print ("<SELECT NAME=Month>
<OPTION VALUE=1>January</OPTION>\n
<OPTION VALUE=2>Febuary</OPTION>\n
<OPTION VALUE=3>March</OPTION>\n
<OPTION VALUE=4>April</OPTION>\n
<OPTION VALUE=5>May</OPTION>\n
<OPTION VALUE=6>June</OPTION>\n
<OPTION VALUE=7>July</OPTION>\n
<OPTION VALUE=8>August</OPTION>\n
<OPTION VALUE=9>September</OPTION>\n
<OPTION VALUE=10>November</OPTION>\n
<OPTION VALUE=11>October</OPTION>\n
<OPTION VALUE=12>December</OPTION>\n
</SELECT>\n");
print ("<SELECT NAME=Year>

<OPTION VALUE=2002>2002</OPTION>\n
<OPTION VALUE=2003>2003</OPTION>\n
<OPTION VALUE=2004>2004</OPTION>\n
</SELECT>\n");
print ("<INPUT TYPE=SUBMIT NAME=SUBMIT Value=\"Submit!\">\n");
print ("</FORM>\n");
require ("footer.php");
?>

Shenlong
20 Jan 2002, 04:55
^^bump^^