Cyloc Posted February 1, 2011 Share Posted February 1, 2011 Hey, I have a problem related to ordering all of my fetched out data by the most recent time they've submitted a form. For instance, I have a form that lets user submit information, some information needs to be displayed ordered by the most recent submission, and not by the lowest ID assigned to the entry from the MySQL database. My sql code: SELECT * FROM events_collection LIMIT $entry, $per_page LIMIT $entry, $per_page is for my pagination tool. Quote Link to comment https://forums.phpfreaks.com/topic/226309-php-ordering-by-most-recent-sql-entry/ Share on other sites More sharing options...
BlueSkyIS Posted February 1, 2011 Share Posted February 1, 2011 I assume you've got a timestamp or other date/time field that records the latest submission. assuming that field is called update_time, SELECT * FROM events_collection ORDER BY update_time LIMIT $entry, $per_page Quote Link to comment https://forums.phpfreaks.com/topic/226309-php-ordering-by-most-recent-sql-entry/#findComment-1168189 Share on other sites More sharing options...
Cyloc Posted February 2, 2011 Author Share Posted February 2, 2011 Ok, thanks. How would I be able to order the data by the greatest ID number in the database to lowest? Since most likely the greatest number (id) will always be the most recent. Quote Link to comment https://forums.phpfreaks.com/topic/226309-php-ordering-by-most-recent-sql-entry/#findComment-1168722 Share on other sites More sharing options...
cyberRobot Posted February 2, 2011 Share Posted February 2, 2011 ...ORDER BY id DESC... Quote Link to comment https://forums.phpfreaks.com/topic/226309-php-ordering-by-most-recent-sql-entry/#findComment-1168834 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.