The following articles mainly describe the differences between MySQL_fetch_row () and MySQL_fetch_array (). We mainly apply the Code to MySQL_fetch_row () by reading data and related timing () different from MySQL_fetch_array.
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], in this way, the data is read by the array subscript, while the array returned by MySQL_fetch_array () contains both the first and key-value pairs. We can read the 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:
Code
- <?php
Connect to the local MySQL database and select test as the operating database.
- $ mysql i = mysqli_connect("localhost", "root", "","test", 3306);
Use the MySQL_fetch_row () function to read data from the user table
- $result = mysqli_query($mysqli, "SELECT * FROM userinfo");
- while($row = mysqli_fetch_array($result))
Read data content cyclically
- {
- ?>
- <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);*/
- ?>
The above content introduces the differences between MySQL_fetch_row () and MySQL_fetch_array (). I hope you will get some benefits.