Hello all. This is my first post on this board and I'm hoping that someone can help me out with this problem. I've spent the past couple of hours searching the forums and while I tried several of the solutions presented, I couldn't get any of them to work for me. I've created an events calendar following some tutorials I found online. My calendar works except for highlighting days with events. Currently, it is only highlighting the last day in my table with an event for each month.
My calendar can be viewed here: http://design.wikedawsum.com/test/pinkcompass/2/pages/cal2.php
If you look at the calendar, it has highlighted the 22nd of March.. which does have an event. But there are also events on the 10th and the 11th of March. Since the 11th is the current day, the events are displayed below the calendar so I'm not really concerned about that one not being highlighted, but the 10th should be highlighted as it has an event.
Below is the code that selects the events for each month and year, and then displays them in the calendar:
$hasEvent = array();
$sql = mysql_query("SELECT day FROM events WHERE month = '$month' AND year = '$year' ORDER BY day");
if (mysql_num_rows($sql) > 0)
{
while ($row = mysql_fetch_array($sql))
{
$hasEvent[$row['day']] = $row['name'];
$today=$row['day'];
}
}
//count up the days, until we've done all of them in the month
while ( $day_num <= $days_in_month )
{
if($day_num == $day && $month == date("n") && $year == date("Y") && $sel == 1)
echo "<td class='selected'><center>$day_num</center></td>";
else if($day_num == $day && $sel == 1)
echo "<td class='selected'><center>$day_num</center></td>";
else if ($day_num == $today) // has an event
echo "<td class='event'><center><a href='cal2.php?sel=1&day=$day_num&month=$month&year=$year'>$day_num</a></center></td>";
else if ($day_count == 1 || $day_count == 7)
{
echo "<td><center><a href='cal2.php?sel=1&day=$day_num&month=$month&year=$year' class='weekend'>$day_num</a></center></td>";
}
else if ($day_num == date("d") && $month == date("n") && $year == date("Y"))
{
echo "<td class='today'><center><a href='cal2.php?sel=1&day=$day_num&month=$month&year=$year'>$day_num</a></center></td>";
}
else {
echo "<td class='normal'></center><a href='cal2.php?sel=1&day=$day_num&month=$month&year=$year'>$day_num</a></center></td>";
}
$day_num++;
$day_count++;
Can anyone tell me how to get this to highlight EVERY day that has an event instead of just the last day in my table?
Thanks in advance for any replies!