PHP access to query MySQL data three ways _php Foundation

Source: Internet
Author: User
1. $row = Mysql_fetch_row ($result);
Returns the array $row of a rule, $row [0] is the first element, $row [1] is the second element, and so on ...
Mysql_num_fields ($result) returns the number of elements of the result.

2. $row = Mysql_fetch_array ($result);

Returns an array of $row. Examples are as follows:
The table structure is as follows:

Username | Password
-------------------------------------
Bourbon | Abc
Berber | Efg

The first run Run $row = mysql_fetch_array ($result) results as follows:

$row [0] = $row ["username"] = "Bourbon"
$row [1] = $row ["password"] = "abc"

The first run Run $row = mysql_fetch_array ($result) results as follows:

$row [0] = $row ["username"] = "Berber"
$row [1] = $row ["password"] = "EFG"


3. $row = Mysql_fetch_object ($result);

Returns an object description row. As in the previous example
The first run of $row = Mysql_fetch_object ($result) results in the following:

$row->username = "Bourbon"
$row->password = "abc"

The second run $row = mysql_fetch_object ($result) results in the following:
$row->username = "Berber"
$row->password = "EFG"

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.