Zoud Posted March 28, 2007 Share Posted March 28, 2007 I have a little question. Were would I enter the LIMIT 0 , 5 tag on the coding below? <?php mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM news ORDER BY id DESC"); while($row = mysql_fetch_array($result)){ ?> I've tried the following: SELECT * FROM news LIMIT 0 , 5 ORDER BY id DESC SELECT * FROM news ORDER BY id LIMIT 0 , 5 DESC SELECT * FROM news ORDER BY id DESC LIMIT 0 , 5 I need it so it will only show the last 5 that were inserted, but I tested each one and they'll eather show all or none. Link to comment https://forums.phpfreaks.com/topic/44656-solved-limit-tag/ Share on other sites More sharing options...
per1os Posted March 28, 2007 Share Posted March 28, 2007 $result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 0,5") OR DIE(mysql_error()); That is the correct way, what error are you getting? Link to comment https://forums.phpfreaks.com/topic/44656-solved-limit-tag/#findComment-216849 Share on other sites More sharing options...
Zoud Posted March 28, 2007 Author Share Posted March 28, 2007 $result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 0,5") OR DIE(mysql_error()); That is the correct way, what error are you getting? I just tried it out your way and now it works. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/44656-solved-limit-tag/#findComment-216852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.