0 AND intMonth = " . ${month . $n} . " AND intYear = " . ${year . $n} . " ORDER BY intDay ASC";
$freebusydata = mysql_query($query) or die ("Select Failed because " . mysql_error());
$freebusydays = array();
$freebusyinfo = array();
while ($row = mysql_fetch_row($freebusydata)){
array_push($freebusydays, $row[0]);
array_push($freebusyinfo, $row[1]);
}
// This sets a flag which will eventually add an extra row if needed so the tables line up
$extra_row = false;
switch(${days_in_month . $n}){
case 28: $extra_row = true; break;
case 29: if (${blank . $n}<6) {$extra_row = true;} break;
case 30: if (${blank . $n}<5) {$extra_row = true;} break;
case 31: if (${blank . $n}<4) {$extra_row = true;} break;
}
//Here we start building the table heads
echo "
";
echo "| ${title . $n} ${year . $n} |
";
echo "| S | M | T | W | T | F | S |
";
//This counts the days in the week, up to 7
$day_count = 1;
echo "";
//first we take care of those blank days
while ( ${blank . $n} > 0 ){
echo "| | ";
${blank . $n} = ${blank . $n}-1;
$day_count++;
}
//sets the first day of the month to 1
$day_num = 1;
$x = 0;
//count up the days, untill we've done all of them in the month
while ( $day_num <= ${days_in_month . $n} ){
If (mktime(0,0,0,${month . $n},$day_num,${year . $n})==mktime(0,0,0,$month,$day,$year)){$dayid = " id='today'";} else {$dayid="";}
switch($day_num){
case $freebusydays[$x]: echo " $day_num | "; $x++; break;
default: echo " $day_num | "; break;
}
$day_num++;
$day_count++;
//Make sure we start a new row every week
if ($day_count > 7){
echo "
";
$day_count = 1;
}
}
//Finaly we finish out the table with some blanks if needed
while ( $day_count >0 && $day_count <=7 ){
echo "| | ";
$day_count++;
}
// Add that extra row if needed
if ($extra_row == true)
{ echo "
| | | | | | | | "; }
echo "
";
if ($oddoreven == 1) {$oddoreven = 2;} else {$oddoreven = 1;}
}
?>
.