Hi all, long time no see! Hope you're all good!
I've started getting back in to PHP and I'm writing a calendar system.
Now I've reached a point where I'm stuck and hopefully you can help!
I'm writing out a calendar for a booking system which shows when a date is booked.
So in the database I have a $StartDate and an $EndDate.
I'm writing out my table with this code:
Code:
<?PHP
for($i=0;$i<$days_in_month;$i++) {
$week_number = date("Week W",mktime(0, 0, 0, $value, ($i+1), $year)); // Finds out the week of the year
$weekday = date("l",mktime(0, 0, 0, $value, ($i+1), $year)); // What weekday it is today
echo "<td title=\"$week_number: $weekday\"><a href=\"\">";
if($weekday==date("l") & $i == (date("j")-1)) {
echo "<!-- This is today -->";
}
if($weekday=="Saturday"||$weekday=="Sunday") { // Is it a weekend?
echo "<b>".($i+1)."</b> ";
}
else {
echo ($i+1)."</a></td>";
}
}
}
?>
Now I'm not sure what to do next.
I need some sort of if statement, that starts a loop based on the $StartDate from the database then changes the background colour of all the dates after $StartDate till $EndDate is reached.
The idea is that the calendar would have different background colours over the dates that are booked.
Any ideas how I go about that?