I have a php calendar at http://idea-palette.com/aleventcal/calendar.php. I want the days that are not part of the current month to show up grayed out(which it does now), and I want it to appear as those are the days of the previous and next month.
As it is now, the days that appear before the first day of the month appear as negative numbers(-1,-2,-3, and so on) and the days that appear after the last day of the month just continue on, so if a month ends on the 31st, then it would read 32, 33, 34, and so on.
I'm trying to figure out a conditional statement with some sort of loop where I could see if it is greater than the total days and then do something else. The problem I see is that the table cell that is being created is being looped, so if I do just $day+1, then instead of 32, it will just read 33.
Here's my code:
for($i=0; $i< $total_rows; $i++)
{
for($j=0; $j<7;$j++)
{
$day++;
//if the current day is less or equal to the total days in the month
if($day>0 && $day<=$total_days_of_current_month)
{
$date_form = "$current_year/$current_month/$day";
echo '<div class="date_has_event" href="#"><td';
//If the date is today then give the td cell the 'today' class
if($date_form == $today)
{
echo ' class="today"';
}
//check if any event stored for the date
if(array_key_exists($day,$events))
{
//adding the date_has_event class to the <td> and close it
echo ' class="date_has_event">'.$day;
//adding the eventTitle and eventContent wrapped inside <span> & <li> to <ul>
echo '<div class="events"><ul>'.$events[$day].'</ul></div>';
}
}
else //if the current day is less or more than the total days in the month
{
//then create a table cell with the current day of the mont
echo '<td class="padding">' . $day . ' </td>'; h
}
}
}