Okay so I've got a query that retrieves events from the table in the DB, and it orders them up by month. Basically what I've got going is it takes the results and groups them by month and orders them by date in ASC format. Here's the code, and in case you were wondering, I had to do it like this because dates were in UNIX timestamp format in the DB.
<?
function display_header($mo, $yr) {
$html = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\">";
$html .= "<tr style=\"background: #8E8E8E;\">";
$html .= "<td colspan=\"3\" style=\"padding: 8px;\">";
$html .= "<span style=\"color: white;\"><b>$mo, $yr</b></span>";
$html .= "</td></tr>";
$html .= "<tr bgcolor=\"#D3D3D3\">";
$html .= "<td style=\"padding: 4px;\" width=\"25%\" align=\"left\">";
$html .= "<span class=\"main_column_sub\" style=\"color: black;\">Event</span></td>";
$html .= "<td style=\"padding: 4px;\" width=\"15%\" align=\"left\">";
$html .= "<span class=\"main_column_sub\" style=\"color: black;\">Date</span></td>";
$html .= "<td style=\"padding: 4px;\" width=\"15%\" align=\"left\">";
$html .= "<span class=\"main_column_sub\" style=\"color: black;\">Location</span></td></tr>";
print $html;
}
function display_event($event_info, $mon, $yr, $id) {
?>
<tr>
<td class="standardsmall" style="padding: 4px;" width="25%" align="left" valign="top">
<a href="mrv_event_calendar.php?month=<?=$mon?>&year=<?=$yr?>&event=<?=$id?>"><?=$event_info['event_title']?></a></td>
<td class="standardsmall" style="padding: 4px;" width="15%" align="left" valign="top"><?=date("M j, Y", $event_info["event_date"])?></td>
<td class="standardsmall" style="padding: 4px;" width="15%" align="left" valign="top"><?=$event_info["event_location"]?></td>
</tr>
<?
}
$no_rows = mysql_num_rows($result);
$last_stamp = array();
while ($event_info = mysql_fetch_array($result)) {
//echo $event_info['event_title'];
$stamp = getdate($event_info['event_date']);
$id = $event_info['event_id'];
$month = $stamp['month'];
$yr = $stamp['year'];
$mon = $stamp['mon'];
if (($month != $last_stamp['month']) || ($yr != $last_stamp['year'])) {
display_header($month, $yr);
$last_stamp = $stamp;
}
display_event($event_info, $mon, $yr, $id);
}
?>
</table>
Now, I need to add spacing between each month of events. I tried adding a </table> tag inside the while loop, but that added a </table> tag after each record, which is no good. I need it to check for the last event of a certain month, and if it's the last, it adds the </table> tag. I hope this all makes sense! thanks in advance.