I’m building an event calendar, and so far, I’ve got the calendar part working correctly, but without it displaying any events.
To be honest, I’m not quite sure how to do this. I’ve found tutorials that show how to make dates with events on them into hyperlinks, but not how to display the actual event name in the calendar cell.
Sudo Code:
[code=php]
while ($row = mysql_fetch_array($sql))
{
$eventDays[$row[‘day’]] = $row[‘event_name’]; //create an array of event names with the day as an index (maybe?)
}
and in the ‘FOR’ loop that’s building day cells:
[code=php]
for($current_day = 1; $current_day <= $days_in_month; $current_day++)
{
if(($week_day_position % 7) == 0)
{
$out .= “</tr><tr>n”; // start a new row
$week_block++;
$week_day_position = 0;
}
$out .= “<td class=”monthDay”>$current_day”;
// I guarantee PHP isn’t going to like this… (sort of like a query against an array?)
foreach($eventDays where $eventDays[‘day’] == $current_day)
{
$out .= $eventDays[‘day’];
}
// Ok, you can stop laughing at me now… 🙂
$out .= “</td>n”;
$week_day_position++;
}
What is the best way of doing this? I figure I could put a query inside the loop, and have it run a query for every single day that it generates a box for, but that seems inefficient.
Thanks for your help ?