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
)