86Stang Posted February 9, 2010 Share Posted February 9, 2010 I've got the following two tables: EVENTS ------------------- event_id title info DATES ------------------- id event_date event_id and I'm pulling the data I need via this query: $qry = "SELECT id,event_date,title,events.event_id FROM events INNER JOIN dates ON dates.event_id = events.event_id ORDER BY event_date asc"; Using a WHILE loop off of that query, I can get that query to generate something akin to: 2010-02-07 Title 1 2010-02-09 Title 2 2010-02-09 Title 3 2010-02-09 Title 4 2010-02-11 Title 5 2010-02-12 Title 6 but what I need is a loop that will show each date only once with the info below it, like: 2010-02-07 Title 1 2010-02-09 Title 2 Title 3 Title 4 2010-02-11 Title 5 2010-02-12 Title 6 I'm sure this is a quick kill for a lot of you out there so I'm hoping a kind soul can help me out. Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 9, 2010 Share Posted February 9, 2010 $output = ''; $current_date = ''; while($record = mysql_fetch_assoc($result)) { //Display date ONLY IF NEW if ($current_date != $record['event_date']) { $current_date = $record['event_date']; $output .= "<b>{$current_date}</b><br>\n"; } $output .= "{$record['title']}<br>\n"; } echo $output; Quote Link to comment Share on other sites More sharing options...
86Stang Posted February 9, 2010 Author Share Posted February 9, 2010 That is SOOO simple! Mucho gracious!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.