Differences between mysql_fetch_array () and mysql_fetch_array ()

Source: Internet
Author: User

Differences between mysql_fetch_assoc () and mysql_fetch_array ()

 

Mysql_fetch_assoc ()

The function retrieves a row from the result set as an associated array.

Returns the associated array generated based on the rows obtained from the result set. If no more rows exist, false is returned.

Tips and comments

Note: mysql_fetch_assoc () is identical to mysql_fetch_array () and the second optional parameter mysql_assoc. It only returns the associated array.

This is also the initial working method of mysql_fetch_array.

 

Tip: If you need a numeric index in addition to the associated index, use mysql_fetch_array ().

 

SQL = "select * From person where lastname = 'adams '";

$ Result = mysql_query ($ SQL, $ con );

Print_r (mysql_fetch_assoc ($ result ));

<HR>

Print_r (mysql_fetch_array ($ result ));

 

?> Output:

 

Array

(

[Lastname] => Adams

[Firstname] => John

[City] => LONDON

)

 

Array

(

[0] => Adams

[Lastname] => Adams

[1] => John

[Firstname] => John

[2] => LONDON

[City] => LONDON

)

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.