Form:http://www.uphtm.com/php/254.html
If we do not look closely will find like mysql_fetch_array () and mysql_fetch_rows () function There is no difference, but look at you will find that they are still very big difference, if you do not understand the difference between the following small series for you to organize Mysql_ Use and examples of Fetch_array () and Mysql_fetch_rows ().
Mysql_fetch_array () function parameters
The Mysql_fetch_array () function takes a row from the result set as an associative array, or as a numeric array, or both
Returns an array based on the rows obtained from the result set, or False if there are no more rows.
Mysql_fetch_array (Data,array_type)
Array_type as follows
MYSQL_ASSOC-Associative arrays
Mysql_num-numeric array
Mysql_both-Default. Simultaneous generation of associative and numeric arrays
Mysql_fetch_rows () function parameters
The Mysql_fetch_row () function takes a row from the result set as a numeric array.
Mysql_fetch_row (data)
From the above, they are all data pointers used. The data pointer is the result of the mysql_query () function, but there is a different parameter behind it, and Mysql_fetch_array () has a array_type parameter and mysql_fetch_rows () does not.
So what's the difference in usage, here's an example
Mysql_fetch_array () and mysql_fetch_rows () can get the field data of the database, the specific differences can be referenced to the collation of the instance:
Mysql_fetch_array () Function Example
- <?php
- $sql = "SELECT * from user";
- $query =mysql_query ($sql);
- $result =mysql_fetch_array ($query);
- echo $result [name];
- echo $resutlt [password];
- ?>
Mysql_fetch_rows () Function Example
- <?php
- $sql = "SELECT * from user";
- $query =mysql_query ($sql);
- $result =mysql_fetch_rows ($query);
- echo $result [1];
- Echo $RESUTLT [2];
- ?>
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
Distinguish between mysql_fetch_array () and mysql_fetch_rows () functions