Can anyone plz explain the difference between mysql_fetch_array() and mysql_fetch_row() using some code examples? I read on the php website but could not grasp it properly.
mysql_fetch array() vs. mysql_fetch_row()
Moderator: General Moderators
mysql_fetch array() vs. mysql_fetch_row()
Hi again
Can anyone plz explain the difference between mysql_fetch_array() and mysql_fetch_row() using some code examples? I read on the php website but could not grasp it properly.
Can anyone plz explain the difference between mysql_fetch_array() and mysql_fetch_row() using some code examples? I read on the php website but could not grasp it properly.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: mysql_fetch array() vs. mysql_fetch_row()
http://uk3.php.net/mysql_fetch_array
The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).
Re: mysql_fetch array() vs. mysql_fetch_row()
By default mysql_fetch_array returns two arrays merged into one, an associative array of field names, and a numeric array like mysql_fetch_row. That's the only difference. You should be using mysql_fetch_object* anyway though, so there's no reason to worry about any differences.
* When you eventually decide to use an abstraction library, which you will, you'll find they all access data like mysql_fetch_object, so it's best to learn that approach from the beginning.
* When you eventually decide to use an abstraction library, which you will, you'll find they all access data like mysql_fetch_object, so it's best to learn that approach from the beginning.
Re: mysql_fetch array() vs. mysql_fetch_row()
thanks onion2k will try the fetch_object
Re: mysql_fetch array() vs. mysql_fetch_row()
thanks jayshieldsjayshields wrote:http://uk3.php.net/mysql_fetch_arrayThe type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).