Home >Backend Development >PHP Tutorial >Three ways to access and query mysql data in PHP_PHP tutorial
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 results are 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 ; bourbon"
$row->password = "abc"
The second time you run $row = mysql_fetch_object($result), the result is as follows:
$row->username = "berber "
$row->password = "efg"
http://www.bkjia.com/PHPjc/316206.html