We apologise for the inconvinience!"; } // list of names for days and months $days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); // number of days in each month $totalDays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // set up some variables to identify the month, date and year to display if(!$currYear) { $currYear = date("Y"); } if(!$currMonth) { $currMonth = date("n"); } if(!$currDay) { $currDay = date("j"); } // if leap year, modify $totaldays array appropriately if (date("L", mktime(0,0,0,$currMonth,1,$currYear))) { $totalDays[2] = 29; } // set up variables to display previous and next months correctly // defaults for previous month $prevMonth = $currMonth-1; $prevYear = $currYear; // if January, decrement year and set month to December if ($prevMonth < 1) { $prevMonth=12; $prevYear--; } // defaults for next month $nextMonth = $currMonth+1; $nextYear = $currYear; // if December, increment year and set month to January if ($nextMonth > 12) { $nextMonth=1; $nextYear++; } // get down to displaying the calendar // find out which day the first of the month falls on $firstDayOfMonth = date("w", mktime(0,0,0,$currMonth,1,$currYear)); include("config.php"); // open a connection to the database $connection = mysql_connect($server, $user, $pass); // formulate the SQL query - same as above $query = "SELECT EventDetail.EventCode,EventDetail.LeaveTime, EventDetail.Date, EventDetail.PickUpTime, Event.Destination, Event.MinStudents, Event.MaxStudents, Event.Description, Event.Cost FROM Event, EventDetail where Event.Code = EventDetail.EventCode and Date >= '" . $currYear . "-" . sprintf("%02d", $currMonth) . "-01' and date <= '" . $currYear . "-" . sprintf("%02d", $currMonth) . "-" . $totalDays[$currMonth] . "'"; // ON ; // run the query on the database $result = mysql_db_query($db,$query ,$connection); $x=0; $dateList=array(); if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $dates = explode("-", $row["Date"]); $dateList[$x] = $dates[2]; $Name[$x] = $row["Destination"] ; $EventDate[$x] = $row["Date"] ; $Code[$x] = $row["EventCode"] ; $Cost[$x] = $row["Cost"] ; $Des[$x] = $row["Description"] ; $LeaveTime[$x] = $row["LeaveTime"] ; $PT[$x] = $row["PickUpTime"] ; $MaxStu[$x]=$row["MaxStudents"] ; $MinStu[$x]=$row["MinStudents"] ; $x++; } } // close connection mysql_close($connection); ?>
" . substr($days[$x],0,3) . ""; } ?>  \n"; } // counter to track the current date $dayCount=1; while ($dayCount <= $totalDays[$currMonth]) { // use this to find out when the 7-day block is complete and display a new row if ($rowCount % 7 == 0) { echo "\n\n"; } // if today, display in different colour // print date if ($dayCount == date("j") && $currYear == date("Y") && $currMonth == date("n")) { echo "\n"; // increment counters $dayCount++; $rowCount++; } ?>
<< >>
" . $dayCount. ""; } else { echo "" . $dayCount . ""; } for ($y=0; $y$Name[$y]"; } } echo "
this month