Hi folks,
I have a list of gigs for a band that I want to display. The gig data will consist of the name of the gig, address, etc.
I know how to store that in the database and select it, but I want to display each gig as a list item under a heading of the MONTH that the gig is in. Like this:
December
- Gig 1
- Gig 2
- Gig 3
In the database I have a table named “gigs” that contains all the data, including a field for the month. I also have another table named “months” that contains all 12 months. So in my query I write “select all the data from both tables where gigs.month = months.month”. This links each gig with it’s proper month and only retrieves months that have gigs in them. But after that, I’m hitting a road block on how to display each gig under each month, and not show any months where there aren’t any gigs. I have a while loop:
while ($row = mysql_fetch_array($result)) {
echo '<h4>' . $row['month'] . '</h4>';
echo '<p>' . $row['day'] . ', ' . $row['month'] . ' ' . $row['gig_date'] . ' - ' . $row['gig_name'] . ' - ' . $row['gig_time'] . '<br/>';
echo $row['address'] . '<br/>';
echo $row['phone'];
}
Unfortunately this gives me:
December
- Gig 1
December
- Gig 2
January
- Gig 3
January
- Gig 4
etc., and I want all gigs per month to under that month’s header.
Any ideas on how to do this?