The mysql_fetch_row query results are incomplete. Why are the results displayed in alternate rows?

WBOY
Release: 2016-10-10 11:56:17
Original
1562 people have browsed it

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 '
'; }
Copy after login
Copy after login

This code can only display part of the results, as shown in the picture: The mysql_fetch_row query results are incomplete. Why are the results displayed in alternate rows?

Database screenshot: The mysql_fetch_row query results are incomplete. Why are the results displayed in alternate rows?

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 '
'; }
Copy after login
Copy after login

Reply content:

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 '
'; }
Copy after login
Copy after login

This code can only display part of the results, as shown in the picture: The mysql_fetch_row query results are incomplete. Why are the results displayed in alternate rows?

Database screenshot: The mysql_fetch_row query results are incomplete. Why are the results displayed in alternate rows?

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 '
'; }
Copy after login
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!