joecooper Posted September 8, 2008 Share Posted September 8, 2008 Hi, this is the code i am using to loop though the database and display all the entrys apart from the first 2 returned: $query = mysql_query("SELECT * FROM games ORDER BY id DESC"); $i = 1; while ($row = mysql_fetch_assoc($query)){ if ($i == 1 || $i == 2){ //do nothing as these are the 2 featured ones and dont need to be displayed here }else{ //code for the table to display data etc... } } but it never returns anything. if i remove the if statement, it works but displays the first 2 that i dont want to include. Link to comment https://forums.phpfreaks.com/topic/123234-list-all-in-db-apart-from-first-2/ Share on other sites More sharing options...
ranjuvs Posted September 8, 2008 Share Posted September 8, 2008 increment the "i" value $query = mysql_query("SELECT * FROM games ORDER BY id DESC"); $i = 1; while ($row = mysql_fetch_assoc($query)){ if ($i == 1 || $i == 2){ //do nothing as these are the 2 featured ones and dont need to be displayed here }else{ //code for the table to display data etc... } $i++; } Link to comment https://forums.phpfreaks.com/topic/123234-list-all-in-db-apart-from-first-2/#findComment-636431 Share on other sites More sharing options...
joecooper Posted September 8, 2008 Author Share Posted September 8, 2008 ah, got it thanks. i did have that but in the wrong place (after the 2 }) thanks! Link to comment https://forums.phpfreaks.com/topic/123234-list-all-in-db-apart-from-first-2/#findComment-636435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.