Home > Backend Development > PHP Tutorial > Three ways to access and query mysql data in Nine Million Bicycles PHP

Three ways to access and query mysql data in Nine Million Bicycles PHP

WBOY
Release: 2016-07-29 08:34:00
Original
1152 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template