Home > Backend Development > PHP Tutorial > PHP uses mysql_fetch_object method to obtain an object set from query results, mysqlfetchobject_PHP tutorial

PHP uses mysql_fetch_object method to obtain an object set from query results, mysqlfetchobject_PHP tutorial

WBOY
Release: 2016-07-13 10:02:54
Original
1114 people have browsed it

PHP uses mysql_fetch_object to obtain the object set from the query results, mysqlfetchobject

This article describes the example of PHP using mysql_fetch_object to obtain the object set from the query results. Share it with everyone for your reference. The specific analysis is as follows:

The mysql_fetch_object function is used to extract result rows from a MySQL result set as an objective array.

mysql_fetch_object syntax:

array mysql_fetch_object (resource $Result_Set)
Copy after login

The Result_Set handle returns a mysql_query query result set.
If the execution is successful, an object containing all data rows will be returned. If it fails, a bool value

will be returned.

Here is the demo code:

<&#63;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_object ($articles)) {
 echo "ISBN = $Row->ISBN<br />\n";
 echo "Title = $Row->Title<br />\n";
 echo "Author = $Row->Author<br />\n";
}
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969478.htmlTechArticlePHP uses mysql_fetch_object to obtain the object set from the query results, mysqlfetchobject. This example describes how PHP uses mysql_fetch_object to obtain the object set from the query results. Method to obtain an object set. ...
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