0){ $m=$prm+$chm; }else{ $m= date("m"); } $no_of_days = date('t',mktime(0,0,0,$m,1,$y)); // This is to calculate number of days in a month $mn=date('F',mktime(0,0,0,$m,1,$y)); // Month is calculated to display at the top of the calendar $mql = date('m',mktime(0,0,0,$m,1,$y)); $yn=date('Y',mktime(0,0,0,$m,1,$y)); // Year is calculated to display at the top of the calendar $j= date('w',mktime(0,0,0,$m,1,$y)); // This will calculate the week day of the first day of the month for($k=1; $k<=$j; $k++){ // Adjustment of date starting $adj .=" "; } ////////////////////////////////// // Connect to database (function in config.php) dbCall($uName, $pWord, $dbName); $q = "SELECT opening, closing, is_closed, ymd FROM `libhours` WHERE ymd LIKE '$yn-$mql-%' ORDER BY ymd"; $r = MYSQL_QUERY($q); while($myrow = mysql_fetch_array($r)) { list($year, $month, $day) = split("-", $myrow[3]); // Get rid of the leading 0 so that things will match up below $day = preg_replace("/^0/", "", $day); $date_data[$day] = array ($myrow[0], $myrow[1], $myrow[2], $myrow[3]); } $calendar = "
\n \n \n \n \n \n \n \n \n \n \n \n \n"; ////// End of the top line showing name of the days of the week////////// //////// Starting of the days////////// for($i=1;$i<=$no_of_days;$i++){ $calendar .= $adj . "\n"; $adj=""; $j++; if($j==7){$calendar.= "\n"; $j=0;} } $calendar.= "\n
«    $mn $yn    »\n

\n
SundayMondayTuesdayWednesdayThursdayFridaySaturday
$i
"; // This will display the date inside the calendar cell if ($date_data[$i][2] == 1) { // Enter the "Closed" Text $calendar .= "Closed"; } elseif ($date_data[$i][0] == "") { // No data for this day; leave blank $calendar .= "

"; } else { $listing = str_replace(" am", "am", $date_data[$i][0]); $listing = str_replace(" pm", "pm", $listing); $listing2 = str_replace(" am", "am", $date_data[$i][1]); $listing2 = str_replace(" pm", "pm", $listing2); // Make sure there's a listing for this day (actually, just a closing hour) if ($listing2 != "") { $calendar.= $listing . " - " . $listing2; // Library's open } } $calendar.= "
\n
"; // Uncomment the lines below to see an array of the values returned from the DB /* print "
";
print_r($date_data);
print "
"; */ ?> Library Hours