rendered paste body<?php$sql = "select date_format(eventDate,'%Y') as year, date_format(eventDate,'%m') as month,date_format(eventDate,'%d') as day,count(eventDate) as numEvents from innactivity where periodSpecific = 'yes' AND date_format(eventDate,'%Y') = ".$year."and date_format(eventDate,'%m') = ".$month." group by eventDate order by eventDate"; $list = $activity->find($sql, false, false); for($i = 1; $i < $numDays+1; $i++, $calCounter++) { $timeStamp = strtotime("$year-$month-$i"); if($i == 1) { //firstday of the month $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $calCounter++) echo "<td> </td>"; } if($calCounter % 7 == 0) echo "</tr><tr>"; foreach ($list as &$value) { if($value == "".$year."-".$month."-".$i){ echo "<td><b><a href='http://www.innattheoaks.com/activitylist.php?view=month&name=".$monthName."&date=".$i."&year=".$year."' onclick=\"sendToForm('".sprintf("%02d/%02d/%04d", $month, $i, $year)."','$field','$form');\">$i</a></b></td>";} } echo "<td><a href='http://www.innattheoaks.com/activitylist.php?view=month&name=".$monthName."&date=".$i."&year=".$year."' onclick=\"sendToForm('".sprintf("%02d/%02d/%04d", $month, $i, $year)."','$field','$form');\">$i</a></td>"; }?>