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
WBOYOriginal
2016-07-13 10:02:351014browse

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...
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