The two functions 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:
Copy codeThe Code is as follows:
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/--> <? Php
// 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
{
?>
<Tr>
<Td align = "center" height = "19"> <? Php echo $ row ["ID"]?> </Td>
<Td align = "center"> <? Php echo $ row ["Name"]?> </Td>
<Td align = "center"> <? Php echo $ row ["Detail"]?> </Td>
</Tr>
<? Php
}
// Close the connection to the database
Mysqli_free_result ($ result );
Mysqli_close ($ mysqli );*/
?>