How can I get the next row from mysql_fetch_array?
I want to get the first and the second row without while.
3 Answers
When you have a while loop, all you essentially do is repeatedly call mysql_fetch_array() as many times as there are rows.
If you want to only show 2 rows, you can simply call mysql_fetch_array() twice, and each time it is called it will grab the next row from the result set.
If you know you're only going to use two results, you should also use a LIMIT 0,2 so you don't load heaps of rows when you are only ever going to use 2, it's a waste of resources and will slow you down over time.