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:
?
|
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'] } ?> |
1
2
3 10 11 |
<🎜>$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"; } ?> |