This article gives a detailed analysis of the differences between mysql_fetch_row () and mysql_fetch_array (). If you need a friend to refer to these two functions, they will return an array, the difference is that the array returned by the first function only contains values. We can only $ row [0],
$ Row [1], which reads data by the array subscript. The array returned by mysql_fetch_array () contains both the first and key values.
In the correct format, we can read data like this (if the database field is username, passwd ):
$ Row ['username'], $ row ['passwd']
In addition, if you use ($ row as $ kay => $ value) for operations, you can directly obtain the database field name.
What's more, mysqli is a new function library provided by php5. (I) indicates improvement and its execution speed is faster.
For example:
The Code is as follows:
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/--> // Connect to the local mysql database and select test as the operating database
$ Mysqli = mysqli_connect ("localhost", "root", "", "test", 3306 );
// Use the mysql_query function to read data from the user table
$ Result = mysqli_query ($ mysqli, "SELECT * FROM userinfo ");
While ($ row = mysqli_fetch_array ($ result) // read data through Loop
{
?>
}
// Close the connection to the database
Mysqli_free_result ($ result );
Mysqli_close ($ mysqli );*/
?>