Mysql_fetch_array returns duplicate data

every time I run mysql_fetch_array, the array is returned with duplicate values , e.g.

Array
(
    [0] => 1
    [row_id] => 1
    [1] => some text
    [first_field] => some text
    [2] => some text
    [second_field] => some text 
}

but I only need individual results in the array, I tried to use

mysql_fetch_array($data, MYSQL_ASSOC);

But it does not matter.

+5
source share
6 answers

This is the assigned functionality mysql_fetch_array(). If you want to not have "duplicates" and just have an associative array, use mysql_fetch_assoc().

Example:

while ($row = mysql_fetch_assoc($data)) { ... }
+12
source

mysql_fetch_array , , . mysql_fetch_assoc. mysql_fetch_row.

+3

mysql_fetch_assoc() mysql_fetch_row

+1

manual:

, , FALSE, . , result_type. MYSQL_BOTH ( ), .. MYSQL_ASSOC, ( mysql_fetch_assoc() ), MYSQL_NUM, ( mysql_fetch_row() ).

, MYSQL_BOTH , . MYSQL_ASSOC MYSQL_NUM, . mysql_fetch_assoc(), .

0

mysql_fetch_array() , ( , ), (.. 0 - , 1, ..). .

, mysql_fetch_assoc() , mysqli, , , mysql_ *.

0
source

mysqli_fetch_array($result, MYSQL_ASSOC)this worked for me, as suggested above for mysql_fetch_assoc, in PHP5.5 it is deprecated now.

0
source

All Articles