slj90 Posted October 15, 2015 Share Posted October 15, 2015 (edited) I want to display data from a MySQL Table but I want to skip the first row of data. My code so far displays all the rows: $result=mysqli_query($con,"SELECT filename FROM images WHERE item_id = '$id'"); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "<img src='../pictures/items/" . $row[filename] . "' height='200'><br><br>"; } } else { echo "You haven't added any items yet."; } What do I need to add to skip the first row? Thanks Edited October 15, 2015 by slj90 Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/ Share on other sites More sharing options...
Solution ginerjm Posted October 15, 2015 Solution Share Posted October 15, 2015 (edited) $first = true; while($row = mysqli_fetch_assoc($result)) { if ($first) { $first = false; continue; } ... ... ... Edited October 15, 2015 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/#findComment-1523343 Share on other sites More sharing options...
mac_gyver Posted October 15, 2015 Share Posted October 15, 2015 without an ORDER BY term in your sql statement, there is NO guarantee that any particular row of matching data is going to always be the first row. what characteristic does your data have that identifies what order you want the rows from the query to be in and what identifying characteristic or value is there that you can use to not include the one particular row in the result set? Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/#findComment-1523344 Share on other sites More sharing options...
ginerjm Posted October 15, 2015 Share Posted October 15, 2015 Sorry about my previous post. For some reason the forum is acting strangely today. I did not spread my code out like that intentionally. Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/#findComment-1523345 Share on other sites More sharing options...
hansford Posted October 15, 2015 Share Posted October 15, 2015 I wish all questions were like this - oh yeah and I got to them first Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/#findComment-1523352 Share on other sites More sharing options...
benanamen Posted October 17, 2015 Share Posted October 17, 2015 Can someone tell me under what circumstances you would want to skip the first row of your query result? I cant for the life of me think of one. Beuler?......Beuler?......Beuler?...... Quote Link to comment https://forums.phpfreaks.com/topic/298618-display-sql-query-results-but-skip-first-row/#findComment-1523566 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.