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 DISTINCT date from calendar where date >= '" . $currYear . "-" . sprintf("%02d", $currMonth) . "-01' and date <= '" . $currYear . "-" . sprintf("%02d", $currMonth) . "-" . $totalDays[$currMonth] . "'"; // 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]; $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+"; } } echo "
this month