Well, of course there is a solution for that as well. In the example I gave, the point was (but probably not the code) that you query on each day, and find all events that's active that certain day. So regardless of span, it will show if it's supposed to.
Of course, there are other ways to do this. Imagine,..
// should obviously be dynamic
$currentMonth = 5;
$days_in_month = 31;
$monthBegin = mktime(1st_day_at_00:00:01);
$monthEnd = mktime(last_day_at_23:59:59);
$res = mysql_query("select * from events where start >= $monthBegin AND start <= $monthEnd");
we now have all the events that start in the current month. We don't care when they end, because they should show up even if they begin last day and end 3rd next month.
$events = array();
while ($oneEvent = mysql_fetch_array($res)) {
$dayStart = date("d", $oneEvent[start]);
if (date("m", $oneEvent[end]) == $currentMonth) {
$dayEnd = date("d", $oneEvent[end]);
} else {
$dayEnd = $days_in_month;
// event spans into next month, wich doesn't show on calendar
}
for ($x = $dayStart; $x <= $dayEnd; $x++)
$events[$x] .= " $oneEvent[id]";
}
foreach ($events AS $key => $val)
$events[$key] = trim($val);
Now, theoretically, $events[1] will hold a list of all event ids active on day 1, $events[2] for day 2 etc etc. Separated by a blank, so explode(" ", $events[x]) to get an array, and do whatever you want to them.
So, when you draw your calendar, just check the $events[current_day] and make some colors, images, or whatever! Alot less queries and cleaner than my last suggestion 🙂