Php queries the mysql database and saves the result to an array. Php queries mysql database and saves the results to an array. This article describes how php queries mysql database and saves the results to an array, the example shows how php uses mysql_fet php to query mysql databases and save the results to arrays.
This article describes how to query the mysql database in php and save the results to an array. The example shows how to query the database using mysql_fetch_assoc in php. For more information, see
This example describes how php queries mysql databases and saves the results to arrays. Share it with you for your reference. The specific analysis is as follows:
The mysql_fetch_assoc function is used here.
The mysql_fetch_assoc syntax is as follows:
?
|
1 |
Array mysql_fetch_assoc (resource $ Result_Set)
|
The sample code is as follows:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
$ UserName = 'abc ';
$ Password = '000000 ';
$ DbHandle = mysql_connect ('localhost', $ UserName, $ Password );
If (! $ DbHandle ){
Die 'no database connection cocould be established .';
}
$ DBName = 'wdb;
If (! Mysql_select_db ($ DBName, $ DbHandle )){
Die 'database cocould not be selected .';
}
$ Query = "select isbn, Title, Author FROM articles ";
$ Articles = mysql_query ($ Query, $ DbHandle ));
While ($ Row = mysql_fetch_assoc ($ articles )){
Echo "ISBN = $ Row ['isbn ']
\ N ";
Echo "Title = $ Row ['title']
\ N ";
Echo "Author = $ Row ['author']
\ N ";
}
?>
|
I hope this article will help you with php programming.
This article describes how to query mysql databases in php and save the results to an array. The example shows how php uses mysql_fet...