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

Source: Internet
Author: User

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

This article mainly introduces how PHP uses mysql_fetch_object to obtain the object set from the query result. The example shows the php operation mysql_fetch_object to query the database. It is very useful. For more information, see

 

 

This example describes how PHP uses mysql_fetch_object to obtain an object set from the query results. Share it with you for your reference. The specific analysis is as follows:

The mysql_fetch_object function is used to extract the result row from a MySQL result set as an array of objectiative.

Mysql_fetch_object Syntax:

?

1

Array mysql_fetch_object (resource $ Result_Set)

The Result_Set handle returns a mysql_query query result set.
If the execution is successful, return the object that contains all data rows. If the execution fails, return the bool value.

The following is the Demo code:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<? Php

$ 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_object ($ articles )){

Echo "ISBN = $ Row-> ISBN <br/> \ n ";

Echo "Title = $ Row-> Title <br/> \ n ";

Echo "Author = $ Row-> Author <br/> \ n ";

}

?>

I hope this article will help you with php programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.