Go into detail on the differences between mysql_fetch_row of and ES4en_ES5en_of

  • 2020-06-03 06:11:00
  • OfStack

Both of these functions return an array, but the difference is that the first function returns an array containing only values, so we can only get $row[0],
$row[1], which reads the data in array subscripts, and mysql_fetch_array() returns an array containing both the first and the key values
We can read the data like this (if the database field is username,passwd) :
$row['username'], $row['passwd']
Also, if you use ($row as $kay = > $value) to operate, also directly to get the database field name.
More importantly, mysqli is a new library provided by php5. (i) represents an improvement and its execution is faster.
Such as:

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php
// Connect to local mysql The database , choose test The library for this operation 
$mysqli = mysqli_connect("localhost", "root", "","test", 3306);
// with mysql_query Function from user Table read data 
$result = mysqli_query($mysqli, "SELECT * FROM userinfo");
while($row = mysqli_fetch_array($result))// Read the contents of the data through a 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);*/
?>


Related articles: