
Jason
Staff
/ Moderator

Dec 19, 2011, 8:29 AM
Post #2 of 3
(379 views)
Shortcut
|
Hi Terry, Try this, you may find this approach easier. Instead of having a separate query for each month, select all the records in one query, then organize them by month/year like this:
list($showsRecords, $showsMetaData) = getRecords(array( 'tableName' => 'shows', 'where' => 'start_date >= NOW()', 'orderBy' => 'start_date ASC', )); $showsByDate = array(); foreach ($showsRecords as $show) { $dateHeader = date("M (Y)", strtotime($show['start_date'])); if (!array_key_exists($header, $showsByDate)) { $showsByDate[$dateHeader] = array(); } $showsByDate[$dateHeader][] = $show; } At the end of this code, the variable $showsByDate will have all of your show records, organized by a month/year header. You can then output this by using two foreach loops like this:
<?php foreach ($showsByDate as $header => $shows): ?> <?php echo $header; ?> <?php foreach ($shows as $show): ?> // output show information here <?php endforeach ?> <?php endforeach ?> Hope this helps get you started. --------------------------------------------------- Jason Sauchuk - Programmer interactivetools.com Hire me! Save time by getting our experts to help with your project. http://www.interactivetools.com/consulting/
|