Home >Backend Development >PHP Tutorial >Three ways to access and query mysql data in PHP_PHP tutorial

Three ways to access and query mysql data in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:03:311116browse

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

www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/316206.htmlTechArticle1. $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 elements of the result...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn