Home > Backend Development > PHP Tutorial > How to use mysql_fetch_row query in PHP to obtain a list of data rows_PHP tutorial

How to use mysql_fetch_row query in PHP to obtain a list of data rows_PHP tutorial

WBOY
Release: 2016-07-13 10:02:35
Original
1023 people have browsed it

How PHP uses mysql_fetch_row query to obtain the data row list

This article mainly introduces the method of PHP using mysql_fetch_row query to obtain the data row list, involving the use of mysql_fetch_row in PHP to operate the database Tips, friends in need can refer to it

The example in this article describes how PHP uses mysql_fetch_row query to obtain a list of data rows. Share it with everyone for your reference. The specific analysis is as follows:

Mysql_fetch_row is used here to query data from the mysql database and save it to the list

The syntax is as follows:

?

1

array mysql_fetch_row (resource $Result_Set)

1
array mysql_fetch_row (resource $Result_Set)

If the execution is successful, the list will be returned. If it fails, false will be returned. The following is the demo code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

$UserName = 'abc';

$Password = '1234';

$DbHandle = mysql_connect ('localhost', $UserName, $Password);

if (!$DbHandle) {

die 'No database connection could be established.';

}

$DBName = 'w3db;

if (!mysql_select_db ($DBName, $DbHandle)) {

die 'Database could not be selected.';

}

$Query = "SELECT ISBN, Title, Author FROM articles";

$articles = mysql_query ($Query, $DbHandle));

while ($Row = mysql_fetch_row($articles)) {

echo "ISBN = $Row['ISBN']
n";

}

?>

?

1 2

3

5 6 7 8 9
10 11
12 13 14 15 16 17
<🎜>$UserName = 'abc';<🎜> <🎜>$Password = '1234';<🎜> <🎜>$DbHandle = mysql_connect ('localhost', $UserName, $Password);<🎜> <🎜>if (!$DbHandle) {<🎜> <🎜>die 'No database connection could be established.';<🎜> <🎜>}<🎜> <🎜>$DBName = 'w3db;<🎜> <🎜>if (!mysql_select_db ($DBName, $DbHandle)) {<🎜> <🎜>die 'Database could not be selected.';<🎜> <🎜>}<🎜> <🎜>$Query = "SELECT ISBN, Title, Author FROM articles";<🎜> <🎜>$articles = mysql_query ($Query, $DbHandle));<🎜> <🎜>while ($Row = mysql_fetch_row($articles)) {<🎜> <🎜>echo "ISBN = $Row['ISBN']
n"; } ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/969967.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969967.htmlTechArticleHow PHP uses mysql_fetch_row query to obtain a list of data rows. This article mainly introduces how PHP uses mysql_fetch_row query to obtain a list of data rows. The method involves using mysql_fetch_r in php...
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