The problem is i cant seem to find a way to highlight a day if a event is on it. Maybe you can help?
My idea was this but it doesnt work..
if ($d == $eventDay) { $f = "eventDay"; }
<?php ############# # Variables # ############# $today = date('j'); // Whats todays date ie. 11 $daysInMonth = date('t'); // How many days in this month ie. 31 $year = date('Y'); // Todays year ie. 2004 $thisMonth = date('F'); // Todays Month ie. January $monthNum = date('m'); // Todays Month ie. 02 $todayDay = date('l'); // Todays day ie. Monday $host = 'localhost'; $user = 'myth'; $pass = '******'; $db = 'sdhs'; $table = 'events'; ############# # Day start # ############# // This Month $dateString = mktime(0,0,0,$monthNum,1,$year); //The date string we need for some info $dayStart = date('w',$dateString); //The number of the 1st day of the week ############# # Day Array # ############# // Format days to shorthand $days = array( 'Sunday' => 'Sun', 'Monday' => 'Mon', 'Tuesday' => 'Tue', 'Wednesday' => 'Wed', 'Thursday' => 'Thu', 'Friday' => 'Fri', 'Saturday' => 'Sat',); ################################## # Days in the Month w/ Leap year # ################################## if(date("L")){ $otherMonths = array( '01' => '31', '02' => '28', '03' => '31', '04' => '30', '05' => '31', '06' => '30', '07' => '31', '08' => '31', '09' => '30', '10' => '31', '11' => '30', '12' => '31',); } else { $otherMonths = array( '01' => '31', '02' => '29', '03' => '31', '04' => '30', '05' => '31', '06' => '30', '07' => '31', '08' => '31', '09' => '30', '10' => '31', '11' => '30', '12' => '31',); } $daysInMonth = $otherMonths[$monthNum]; // How many days in this month ie. 31 ############### # Month Array # ############### // Format integar months to a name $monthFormat = array( '01' => 'January', '02' => 'Febuary', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December',); ########################### # Css Variables / Options # ########################### $calWidth = '350'; // Use size in Pixels, leave the px out $dayWidth = '50'; // Use size in Pixels, leave the px out $dayAlign = 'center'; // Use "center", "left", "right", or leave blank $dayFill = 'TDayFill'; // Class name to use to fill in the days with dates $dateEmpty = 'TDayEmpty'; // Class name to use to fill in the empty days without dates $dateWidth = '50'; // Use size in Pixels, leave the px out $dateFill = 'TDateFill'; // Class name to use to fill in the date with dates $dateAlign = 'center'; // Use "center", "left", "right", or leave blank $dateText = 'TDateText'; // Class name to use to stylize in the dates $tableHeader = 'TTableHeader'; $dayText = 'TDayText'; $monthAlign = 'center'; $monthText = 'TMonthText'; $calFill = 'TCalFill'; ######### # Start # ######### // Open the outside table print "<table width=\"$calWidth\" class=\"$calFill\"><tr><td>"; ################ # Table Header # ################ echo ' <table width="'.$calWidth.'" class="'.$tableHeader.'"> <tr> <td colspan="7"><div align="'.$monthAlign.'" class="'.$monthText.'">' . $monthFormat[$monthNum] . '</div></td> </tr> <tr> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Sunday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Monday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Tuesday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Wednesday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Thursday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Friday'] . '</div></td> <td width="'.$dayWidth.'" class="'.$dayFill.'"><div align="'.$dayAlign.'" class="'.$dayText.'">' . $days['Saturday'] . '</div></td> </tr> '; ############ # Pre-Loop # ############ echo '<tr>'; ################### # Loop Empty days # ################### $dayStart = $dayStart + 1; for( $i = 1; $i < $dayStart; $i++ ) { echo '<td class="'.$dayEmpty.'" width="'.$dayWidth.'"><div align="'.$dayAlign.'" class="dateText"></div></td>'; } ############################### # Connect to MySQL / Query it # ############################### $link = mysql_connect("$host", "$user", "$pass") or die ("Could not connect to MySQL"); mysql_select_db ("$db") or die ("Could not select database"); $query = "SELECT * FROM $table WHERE year = $year AND month = $monthNum"; $result = mysql_query ($query) or die ("Query failed"); while ($row = mysql_fetch_assoc($result)){ $eventDay = $row['day']; ################# # Loop the rest # ################# $currentPosition = $dayStart; // Current column position for ($i = $currentPosition; $d < $daysInMonth; $i++) { $d = $d + 1; // Change the text class if its today or not if ($d == $today) { ($t = "TnowText") && $f = ("TnowFill"); } else { ($t = "TdateText") && $f = ("TdateFill"); } echo "<td width=\"$dateWidth\" class=\"$f\">" . "<div align=\"$dateAlign\" class=\"$t\">" . substr($d+100,1) . "</div>" . "</td>"; if ($i == 07 || $i == 14 || $i == 21 || $i == 28) { echo "</tr><tr>\n"; } } } ############################# # Fill the rest of the days # ############################# $a = 35 - $daysInMonth - $dayStart + 1; for ($e = 0; $e < $a; $e++) { echo "<td width=\"$dateWidth\" class=\"emptyDay\"> </td>"; } ####### # End # ####### // Close the inside table print "</tr></table>"; // Close the outside table print "</td></tr></table>"; ?>