Php: three methods for querying mysql data _ PHP Tutorial

Source: Internet
Author: User
You can use php to query mysql data. 1. $ rowmysql_fetch_row ($ result); returns a regular array $ row, $ row [0] is the first element, $ row [1] is the second element, and so on... element 1 of the result returned by mysql_num_fields ($ result. $ row = mysql_fetch_row ($ result );
Returns a regular array $ row. $ row [0] is the first element, $ row [1] is the second element, and so on...
The number of elements returned by mysql_num_fields ($ result.

2. $ row = mysql_fetch_array ($ result );

Returns an array $ row. for example:
The table structure is as follows:

Username | password
-------------------------------------
Bourbon | abc
Berber | efg

Run $ row = mysql_fetch_array ($ result) for the first time. The result is as follows:

$ Row [0] = $ row ["username"] = "bourbon"
$ Row [1] = $ row ["password"] = "abc"

Run $ row = mysql_fetch_array ($ result) for the first time. The result is as follows:

$ Row [0] = $ row ["username"] = "berber"
$ Row [1] = $ row ["password"] = "efg"


3. $ row = mysql_fetch_object ($ result );

Returns an object description line. for example
Run $ row = mysql_fetch_object ($ result) for the first time. The result is as follows:

$ Row-> username = "bourbon"
$ Row-> password = "abc"

Run $ row = mysql_fetch_object ($ result) for the second time. The result is as follows:
$ Row-> username = "berber"
$ Row-> password = "efg"

Http://www.bkjia.com/PHPjc/316206.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316206.htmlTechArticle1. $ row = mysql_fetch_row ($ result); returns a regular array $ row, $ row [0] is the first element, and $ row [1] is the second element, and so on... elements returned by mysql_num_fields ($ result...

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.