dexthageek
IS-IT--Management
I have come across a great calendar script however, im having a hard time trying to figure out how to input my DB records to the proper dates in the calendar.
Here is the code.
Thanks in Advance
Mike
Here is the code.
Code:
<?php
$today=date(Ymd);
$calMonth=$_GET[calMonth];
$calYear=$_GET[calYear];
if ((!$calMonth) && (!$calYear)) {
$calMonth = date ("m");
$calYear = date ("Y");
}
$monthlydate=$calYear.$calMonth."00";
$ThisMonth=$calYear . $calMonth;
$ThisMonth=($ThisMonth*100);
// Calculate the viewed Month.
$Timestamp = mktime (0, 0, 0, $calMonth, 1, $calYear);
$MonthName = date("F", $Timestamp);
// Make a table with the proper month.
print ("<P ALIGN=LEFT><TABLE BORDER=0 CELLPADDING=1 WIDTH=97% CELLSPACING=0 BGCOLOR=BLACK ALIGN=CENTER><tr><td><TABLE BORDER=0 CELLPADDING=2 WIDTH=100% CELLSPACING=1 ALIGN=CENTER><TR BGCOLOR=BLACK><TD ALIGN=CENTER COLSPAN=7><FONT SIZE=4 COLOR=WHITE><B>$MonthName $calYear</B></FONT></TD></TR><TR BGCOLOR=BLACK><TD ALIGN=CENTER WIDTH=15%><B><FONT SIZE=2 COLOR=WHITE>Sun</FONT></B></TD><TD ALIGN=CENTER WIDTH=14%><B><FONT SIZE=2 COLOR=WHITE>Mon</FONT></B></TD><TD ALIGN=CENTER WIDTH=14%><B><FONT SIZE=2 COLOR=WHITE>Tue</FONT></B></TD><TD ALIGN=CENTER WIDTH=14%><B><FONT SIZE=2 COLOR=WHITE>Wed</FONT></B></TD><TD ALIGN=CENTER WIDTH=14%><B><FONT SIZE=2 COLOR=WHITE>Thu</FONT></B></TD><TD ALIGN=CENTER WIDTH=14%><B><FONT SIZE=2 COLOR=WHITE>Fri</FONT></B></TD><TD ALIGN=CENTER WIDTH=15%><B><FONT SIZE=2 COLOR=WHITE>Sat</FONT></B></TD></TR>\n");
$MonthStart = date("w", $Timestamp);
if ($MonthStart == 0) {
$MonthStart = 7;
}
$LastDay = date("d", mktime (0, 0, 0, $calMonth+1, 0, $Year));
$calStartDate = -$MonthStart;
for ($k = 1; $k <= 6; $k++) {
//SET 6 ROWS
print ("<TR BGCOLOR=WHITE>");
for ($i = 1; $i <= 7; $i++) {
//SET 7 COLUMNS
$calStartDate++;
if (($calStartDate <= 0) || ($calStartDate > $LastDay)) {
print ("<TD BGCOLOR=#DDDDDD height=110 valign=top align=left> </TD>");
} elseif (($calStartDate >= 1) && ($calStartDate <= $LastDay)) {
//IF TODAY
if ($calStartDate<"10") {$MyDay="0$calStartDate";} else {$MyDay="$calStartDate";}
$ThisDay="$calYear$calMonth$MyDay";
if (($MyDay==date("d")) AND ($calMonth==date("m")) AND ($calYear==date("Y"))) {
print ("<TD BGCOLOR=#FFCCCC height=110 valign=top align=left><FONT SIZE=2><b>$calStartDate</b></font>\n");
} else {
print ("<TD height=110 valign=top align=left><FONT SIZE=2><b>$calStartDate</b></font>\n");
}
print ("</TD>");
}
}
print ("</TR>\n");
}
print ("</TABLE></td></tr><TR BGCOLOR=WHITE><TD>\n");
// Make the form.
print ("<FORM METHOD=GET>\n");
print ("Select another month to view:\n");
print ("<SELECT NAME=calMonth>\n");
if ($calMonth=="12") { print ("<OPTION SELECTED VALUE=01>January</OPTION>\n"); } else { print ("<OPTION VALUE=01>January</OPTION>\n"); }
if ($calMonth=="01") { print ("<OPTION SELECTED VALUE=02>February</OPTION>\n");} else { print ("<OPTION VALUE=02>February</OPTION>\n"); }
if ($calMonth=="02") { print ("<OPTION SELECTED VALUE=03>March</OPTION>\n"); } else { print ("<OPTION VALUE=03>March</OPTION>\n"); }
if ($calMonth=="03") { print ("<OPTION SELECTED VALUE=04>April</OPTION>\n"); } else { print ("<OPTION VALUE=04>April</OPTION>\n"); }
if ($calMonth=="04") { print ("<OPTION SELECTED VALUE=05>May</OPTION>\n"); } else { print ("<OPTION VALUE=05>May</OPTION>\n"); }
if ($calMonth=="05") { print ("<OPTION SELECTED VALUE=06>June</OPTION>\n"); } else { print ("<OPTION VALUE=06>June</OPTION>\n"); }
if ($calMonth=="06") { print ("<OPTION SELECTED VALUE=07>July</OPTION>\n"); } else { print ("<OPTION VALUE=07>July</OPTION>\n"); }
if ($calMonth=="07") { print ("<OPTION SELECTED VALUE=08>August</OPTION>\n"); } else { print ("<OPTION VALUE=08>August</OPTION>\n"); }
if ($calMonth=="08") { print ("<OPTION SELECTED VALUE=09>September</OPTION>\n"); } else { print ("<OPTION VALUE=09>September</OPTION>\n"); }
if ($calMonth=="09") { print ("<OPTION SELECTED VALUE=10>October</OPTION>\n"); } else { print ("<OPTION VALUE=10>October</OPTION>\n"); }
if ($calMonth=="10") { print ("<OPTION SELECTED VALUE=11>November</OPTION>\n"); } else { print ("<OPTION VALUE=11>November</OPTION>\n"); }
if ($calMonth=="11") { print ("<OPTION SELECTED VALUE=12>December</OPTION>\n"); } else { print ("<OPTION VALUE=12>December</OPTION>\n"); }
print ("</SELECT>\n");
print ("<SELECT NAME=calYear>\n");
$MyNextYear=$calYear+1;
$ThisYear=date("Y");
if ($calMonth=="12") {
print ("<OPTION SELECTED VALUE=$MyNextYear>$MyNextYear</OPTION>\n");
} else {
print ("<OPTION SELECTED VALUE=$calYear>$calYear</OPTION>\n");
}
for ($nextyear = $ThisYear; $nextyear <= 2015; $nextyear++) {
print ("<OPTION VALUE=$nextyear>$nextyear</OPTION>\n");
}
print ("</SELECT><INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=\"Display\"></FORM></TD></TR></TABLE></P>\n");
?>
Thanks in Advance
Mike