What are the differences between the two php statements? First statement: $ SQL & quot; select * fromtable & quot; $ querymysql_query ($ SQL); while ($ rowmysql_fetch_array ($ query);) {echo & quot; output & quot;}: What are the differences between $ SQL & quot; select * fromtable php?
First writing:
$ SQL = "select * from table ";
$ Query = mysql_query ($ SQL );
While ($ row = mysql_fetch_array ($ query );){
Echo "output ";
}
Second writing:
$ SQL = "select * from table ";
$ Query = mysql_query ($ SQL );
$ Row = mysql_fetch_array ($ query );
While ($ row ){
Echo "output ";
}
------ Solution --------------------
While ($ row = mysql_fetch_array ($ query), check whether the value of the $ row = mysql_fetch_array ($ query) expression is true. If yes, execute the loop part, then return to the front and check the value of $ row = mysql_fetch_array ($ query) in this loop.
In the second example, the value of $ row does not change, that is, it either never executes the loop body or runs forever.
You may need to understand the role of mysql_fetch_array.
------ Solution --------------------
Upstairs. In addition to mysql_fetch_array (); you can also call the mysql_fetch_object () method to obtain the SQL query result. The specific usage will not be described in detail. Baidu has many
------ Solution --------------------
PHP code
While ($ row = mysql_fetch_array ($ query) {// mysql_fetch_array contains a resource locating pointer. each call points to downstream data. // because it is an entry condition loop, then $ row is formed, which is downstream data at each judgment. this can determine whether it has reached the end of the data. // The second floor is similar.
------ Solution --------------------
Solution on the second floor, sprinkling flowers
------ Solution --------------------
The difference is that the former is correct and the latter is wrong.
------ Solution --------------------
The first is traversal, and the second is the first line, which is so simple.
------ Solution --------------------
The first syntax seems to be incorrect (a semicolon is added to the while expression );
The second statement seems like an endless loop.
--------------------------------
Based on the plug-in extension function provided by the CSDN forum, I have made a signing tool and shared it with you. we welcome Technical Exchange :)
------ Solution --------------------
The result of the second loop... It seems that I have had an endless loop .. It can only be restarted ..