Differences between mysqli_fetch_assoc () and mysqli_fetch_row () in php _ PHP Tutorial

Source: Internet
Author: User
Differences between mysqli_fetch_assoc () and mysqli_fetch_row () in php. Both mysqli_fetch_assoc () and mysqli_fetch_row () are used to return the query results to an array. both return the first row and move the pointer down the row. Difference: mysqli_fetch_assoc () uses the keyword mysqli_fetch_assoc () and mysqli_fetch_row () to return the query results to an array. both return the first row and move the pointer down one row.

Difference: mysqli_fetch_assoc () is indexed with a keyword. For example:
$ Row = $ result-> fetch_assoc ();
Echo $ row ['username'];

However, mysqli_fetch_row () uses the numeric index value. For example:
$ Row = $ result-> fetch_row ();
Echo $ row [0]; // note: "0" indicates the first field in the table (that is, username is the first field in the table ).

Another function: mysqli_fetch_object () is used to return a row to an object, and then take the value through the class method, for example:
$ Row = $ result-> fetch_object ();
Echo $ row-> username;

Values () and mysqli_fetch_row () both return the query results to an array. they both return the first row and move the pointer down the row. Difference: mysqli_fetch_assoc () keyword...

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.