Home > Article > Backend Development > Three ways to access and query mysql data in Nine Million Bicycles PHP
1. $row = mysql_fetch_row($result);
Returns a regular array $row, $row[0] is the first element, $row[1] is the second element, and so on...
mysql_num_fields( $result) returns the number of elements in the result.
2. $row = mysql_fetch_array($result);
Returns an array $row. For example:
The table structure is as follows:
username | password
-------------------------------- -------------------
bourbon | abc
berber | efg
The first time you run $row = mysql_fetch_array($result), the result is as follows:
$row[0 ] = $row["username"] = "bourbon"
$row[1] = $row["password"] = "abc"
The first time you run $row = mysql_fetch_array($result), the result is as follows:
$row[0] = $row["username"] = "berber"
$row[1] = $row["password"] = "efg"
3. $row = mysql_fetch_object($result);
Return a Object description row. As in the above example, if you run $row = mysql_fetch_object($result) for the first time, the results are as follows:
$row->username = "bourbon"
$row->password = "abc"
The second time Run $row = mysql_fetch_object($result) and the result is as follows:
$row->username = "berber"
$row->password = "efg"
The above introduces the three methods of Nine Million Bicycles PHP to access and query mysql data, including the content of Nine Million Bicycles. I hope it will be helpful to friends who are interested in PHP tutorials.