Php queries the mysql database and saves the results to the array, mysql array. Php queries the mysql database and saves the results to an array. This article describes how php queries the mysql database and saves the results to an array. I will share with you how to query the mysql database in php and save the results to an array, mysql array.
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:
array mysql_fetch_assoc (resource $Result_Set)
The sample code is as follows:
<?php$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_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.
Examples in this article describes how php queries the mysql database and saves the results to an array. I will share it with you for your reference...