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()); Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/64150-solved-mysql-order-by/#findComment-319708 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.