Hi everyone,
I have been trying to figure this one out for hours and I have about had it. I am trying to pull event details from a table (events) and arrange them by their respective date. Here comes the tricky part - some events have a specific date (DATE field, YYYY/MM/DD - column event_date) and others have only Month and Year - also DATE, stored as user submitted YYYY/MM/01 (column event_date_gen) ... the 01 since they are not entering a specific day.
Here is the SQL I am using... although I have tried MANY variations:
Then I am using a WHILE loop to return the results:Code:SELECT event_id, event_title, DATE_FORMAT(event_date, '%W, %b %D, %Y') AS event_date, DATE_FORMAT(event_date_gen, '%M, %Y') AS event_date_gen, event_description FROM events ORDER BY event_date DESC, event_date_gen DESC"
The results I am getting, with the above SQL, is as follows:PHP Code:<?php
while ($eventDetails = mysql_fetch_assoc($getEvents)) {
echo "<p>$eventDetails[event_title] - $eventDetails[event_date]$eventDetails[event_date_gen]</p>";
}
?>
As you can see, the event_date_gen ends up at the bottom instead of after the event on Sep 13th. Different variations of the SQL have returned similar out of order results.Annual Meeting and Reception - Sunday, Sep 13th, 2009
Spring Lecture with Cori Ellison - Sunday, Feb 28th, 2010
Trip to New York City Opera - Partenope - Sunday, Apr 11th, 2010
Pot Luck Supper and Opera Video - October, 2009
Wine Tasting Benefit - October, 2009
PLEASE help. This is holding me back on this project.
Many thanks,
Ben



Reply With Quote

Bookmarks