Northern Flame Posted August 9, 2007 Share Posted August 9, 2007 hello, I am trying to order my data by the id, but i only want to show the latest 5 that were entered. I know how to only display 5, but it shows the first 5, not the last 5, can anyone help? $limit = 5; $query = "SELECT * FROM table ORDER BY id LIMIT $limit"; $result = mysql_query($query) or die("ERROR " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/64150-solved-mysql-order-by/ Share on other sites More sharing options...
lightningstrike Posted August 9, 2007 Share Posted August 9, 2007 $limit = 5; $query = "SELECT * FROM table ORDER BY id DESC LIMIT $limit"; $result = mysql_query($query) or die("ERROR " . mysql_error()); That should work. Link to comment https://forums.phpfreaks.com/topic/64150-solved-mysql-order-by/#findComment-319707 Share on other sites More sharing options...
Northern Flame Posted August 9, 2007 Author Share Posted August 9, 2007 alright thanks Link to comment https://forums.phpfreaks.com/topic/64150-solved-mysql-order-by/#findComment-319708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.