double results in my array ( mysql_fetch_array )

From the manual:

mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both

By default, mysql_fetch_array gives both associative and numeric indexes. You don’t want this. You can limit it with the second parameter:

$query_result_array = mysql_fetch_array($query_result, MYSQL_NUM); // numeric keys only
$query_result_array = mysql_fetch_array($query_result, MYSQL_ASSOC); // associative keys only

You can also use mysql_fetch_row to only get numeric keys, or mysql_fetch_assoc to only get associative keys.

$query_result_array = mysql_fetch_row($query_result); // numeric keys only
$query_result_array = mysql_fetch_assoc($query_result); // associative keys only

Leave a Comment