Difference between mysql_fetch_array () and mysql_fetch_rows () functions, mysqlfetchrows

Source: Internet
Author: User

Difference between mysql_fetch_array () and mysql_fetch_rows () functions, mysqlfetchrows

Form: http://www.uphtm.com/php/254.html

If we do not take a closer look, we will find that the functions like mysql_fetch_array () and mysql_fetch_rows () have no difference, but you will find that they are quite different from each other, if you do not know the differences between this function, I will explain the usage and examples of mysql_fetch_array () and mysql_fetch_rows.

Mysql_fetch_array () function parameters

The mysql_fetch_array () function retrieves a row from the result set as an associated array, or an array of numbers, or both.
Returns the array generated based on the rows obtained from the result set. If no more rows exist, false is returned.

Mysql_fetch_array (data, array_type)

Array_type is as follows:

MYSQL_ASSOC-associated array
MYSQL_NUM-number Array
MYSQL_BOTH-default. Generate join and numeric arrays at the same time

Mysql_fetch_rows () function parameters

The mysql_fetch_row () function retrieves a row from the result set as a numeric array.

Mysql_fetch_row (data)

From the above, they are all data pointers used. This Data Pointer is generated by the mysql_query () function, but there is a different parameter later. mysql_fetch_array () has the array_type parameter while mysql_fetch_rows () does not.

So what are the differences in usage? Let's take a look at the example below.

Both mysql_fetch_array () and mysql_fetch_rows () can obtain the field data of the database. For details about the differences, refer to the example to organize:

Example of the mysql_fetch_array () function

Example of mysql_fetch_rows () function

In summary, mysql_fetch_array () is an array and can be associated with an array. While mysql_fetch_rows is an object that cannot be associated with an array, the difference is here.

Form: http://www.uphtm.com/php/254.html

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.