When using the mysql_fetch_row function to query the database results, only the results of alternate rows in the database are displayed instead of the complete results. What is the reason? The code is as follows:
<code>while(mysql_fetch_row($result)){ echo '<pre class="brush:php;toolbar:false">'; print_r(mysql_fetch_row($result)); echo ''; }
This code can only display part of the results, as shown in the picture:
Database screenshot:
2. Use the following code to query all results. Why?
<code>while($arr = mysql_fetch_row($result)){ echo '<pre class="brush:php;toolbar:false">'; print_r($arr); echo ''; }
When using the mysql_fetch_row function to query the database results, only the results of alternate rows in the database are displayed instead of the complete results. What is the reason? The code is as follows:
<code>while(mysql_fetch_row($result)){ echo '<pre class="brush:php;toolbar:false">'; print_r(mysql_fetch_row($result)); echo ''; }
This code can only display part of the results, as shown in the picture:
Database screenshot:
2. Use the following code to query all results. Why?
<code>while($arr = mysql_fetch_row($result)){ echo '<pre class="brush:php;toolbar:false">'; print_r($arr); echo ''; }
It should be that every time mysql_fetch_row($result) is executed, it will move the pointer back one
The first time it is executed in the brackets after while, there is no output
Then it is executed once in the code block and output
Then it is executed again in a loop There is no output
Then the code block is executed once and output
Then the condition in the while is false and stops
Every time fetch is completed, it is equivalent to moving the pointer down one bit. The first way of writing moves down two bits each time (once in while and once in print_r), so every other one is output.