I'm creating an availability calendar for a cottage which displays all the days for each month in a normal calendar format. For each day that is booked I want it to be coloured red and for each day that isn't booked I want it to be coloured green. I'm storing the booking information in mysql based on the arrival date and a numerical value representing the number of days booked to stay.
Now, I've got each day to respond to the arrival date but I can't for the life of me figure out how to get the rest of the days following the arrival date to represent being booked and thus coloured red.
Here's what I have so far.
<table width="631" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr class="topdays">
<td><div align="center">Saturday</div></td>
<td><div align="center">Sunday</div></td>
<td><div align="center">Monday</div></td>
<td><div align="center">Tuesday</div></td>
<td><div align="center">Wednesday</div></td>
<td><div align="center">Thursday</div></td>
<td><div align="center">Friday</div></td>
</tr>
<tr valign="top" bgcolor="#CCCCCC">
<?
for ($i = 1; $i <= $first_day_of_month; $i++) {
$days_so_far = $days_so_far + 1;
$count_boxes = $count_boxes + 1;
echo "<td width=\"100\" height=\"125\" class=\"beforedayboxes\"></td>\n";
}
for ($i = 1; $i <= $days_in_month; $i++) {
$days_so_far = $days_so_far + 1;
$count_boxes = $count_boxes + 1;
IF($_GET['month'] == $todays_month+1){
IF($i == $todays_date){
$class = "highlighteddayboxes";
} ELSE {
$class = "dayboxes";
}
} ELSE {
IF($i == 1){
$class = "highlighteddayboxes";
} ELSE {
$class = "dayboxes";
}
}
IF(isset($events[$i])){
while (list($key, $val) = each ($nightstay[$i])) {
$class = "calendarbooked";
}
}
echo "<td width=\"100\" height=\"125\" class=\"$class\">\n";
$link_month = $_GET['month'] - 1;
echo "<div align=\"right\"><span class=\"toprightnumber\">\n$i </span></div>\n";
IF(isset($events[$i])){
echo "<div align=\"left\"><span class=\"eventinbox\">\n";
while (list($key, $value) = each ($events[$i])) {
}
echo "</span></div>\n";
}
echo "</td>\n";
IF(($count_boxes == 7) AND ($days_so_far != (($first_day_of_month-1) + $days_in_month))){
$count_boxes = 0;
echo "</TR><TR valign=\"top\">\n";
}
}
$extra_boxes = 7 - $count_boxes;
for ($i = 1; $i <= $extra_boxes; $i++) {
echo "<td width=\"100\" height=\"125\" class=\"afterdayboxes\"></td>\n";
}
$time_end = getmicrotime();
$time = round($time_end - $time_start, 3);
?>
</tr>
</table>
Any help would be greatly appreciated.
Thanks.