dannybrazil Posted March 24, 2008 Share Posted March 24, 2008 Hello i have this code written : $result = mysql_query("SELECT * FROM "my table" ORDER BY Date") and i want to get the database to show on my page sorted by the date , newest FIRST and down twards the oldest some one ? thanks Link to comment https://forums.phpfreaks.com/topic/97646-order-by-command/ Share on other sites More sharing options...
cooldude832 Posted March 24, 2008 Share Posted March 24, 2008 the parameter ASC, DESC can be added to any order by query to change direction of the ordering using natural sorting method i.e integer, float or strings Link to comment https://forums.phpfreaks.com/topic/97646-order-by-command/#findComment-499606 Share on other sites More sharing options...
rhodesa Posted March 24, 2008 Share Posted March 24, 2008 Yeah, so as long as your 'date' column was some sort of Date/Time type or even and integer with a unix timestamp in it, it would be: $result = mysql_query("SELECT * FROM `tableName` ORDER BY `date` DESC"); Link to comment https://forums.phpfreaks.com/topic/97646-order-by-command/#findComment-499612 Share on other sites More sharing options...
Codein Posted March 24, 2008 Share Posted March 24, 2008 You also need to fetch the data from the result. while ($info = mysql_fetch_assoc($result)) { echo("$info['name'] - $info['foo'] - $info['date']"); } You shouldn't use the above code though. It should give you a good idea on how to return the data though. Link to comment https://forums.phpfreaks.com/topic/97646-order-by-command/#findComment-499617 Share on other sites More sharing options...
dannybrazil Posted March 24, 2008 Author Share Posted March 24, 2008 cool working 10x Link to comment https://forums.phpfreaks.com/topic/97646-order-by-command/#findComment-499625 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.