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