These two functions return an array, the difference being that the first function returns an array that contains only the values we can only $row[0],
$row [1], which reads the data as an array subscript, and mysql_fetch_array () returns an array that contains both the first and key values
On the form, we can read the data in this way (if the database field is USERNAME,PASSWD):
$row [' username '], $row [' passwd ']
Furthermore, if you use ($row as $kay => $value), you can also get the field name of the database directly.
More important, Mysqli is a new library of functions provided by PHP5, and (i) represents an improvement that performs faster.
For example:
Copy Code code as follows:
Code highlighting produced by Actipro Codehighlighter (freeware) http://www.CodeHighlighter.com/--><?php
Connect to local MySQL database, select Test as Action Library
$mysqli = Mysqli_connect ("localhost", "root", "" "," Test ", 3306);
Reading data from the user table using the Mysql_query function
$result = Mysqli_query ($mysqli, "SELECT * from UserInfo");
while ($row = Mysqli_fetch_array ($result))//Read data content by looping
{
?>
<tr>
<TD align= "center" height= "><?php echo $row [" ID "]?></td>
<TD align= "center" ><?php Echo $row ["Name"]?></td>
<TD align= "center" ><?php Echo $row ["Detail"]?></td>
</tr>
<?php
}
To close a connection to a database
Mysqli_free_result ($result);
Mysqli_close ($MYSQLI);
?>