hookedupphat Posted January 22, 2010 Share Posted January 22, 2010 Hello everyone, long time reader, first time poster... I'm having an issue with a calendar program I'm working on, it involves a mySQL database with a date field. Basically I am pulling up every 'event' from the database that corresponds to a particular user. I cannot seem to get them to order correctly. Right now they are ordered by the month name, which will put August before december, and so on. How can I get them to order chronologically, or at the very least manage it so I can call a particular month? $courses = explode(",", $cid); foreach($courses as $i){ $sql .= "cid = '$i' OR "; } $sql = rtrim($sql, "OR "); $select_query="SELECT eid,cid,DATE_FORMAT(date, '%b. %D, %Y')AS date,name,type from courses_events WHERE ($sql) ORDER BY date ASC"; Hope someone can help, or at least point me in the right direction! Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/189475-php-mysql-date-ordering-issue-need-help-please/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2010 Share Posted January 22, 2010 You need to ORDER BY the original column. When you use an alias name that is the same as the column name, the alias value is used. I would pick a different alias name. Quote Link to comment https://forums.phpfreaks.com/topic/189475-php-mysql-date-ordering-issue-need-help-please/#findComment-1000111 Share on other sites More sharing options...
Wright Posted January 22, 2010 Share Posted January 22, 2010 Specific situations require specific methods my friend! Do as PF says or use PHP to manually order them! Quote Link to comment https://forums.phpfreaks.com/topic/189475-php-mysql-date-ordering-issue-need-help-please/#findComment-1000147 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.