Jump to content

mysqli_fetch_array()


Love2c0de

Recommended Posts

Hi, I have a select query where I query 2 tables and retrieve all the data. When I send the results through a while loop, printing the rows, I am getting the information I need but it seems to be an indexed and associative array all in one. Here is sample output from 1 row.

Array
(
   [0] => 1
   [id] => 1
   [1] => dsdaddda
   [username] => dsdaddda
   [2] => $2a$08$xi0Aem5dgJkyZbFbXVb6/.CY9AxFt0jJ.5W5ohamRyEgAgFiVHh22
   [password] => $2a$08$xi0Aem5dgJkyZbFbXVb6/.CY9AxFt0jJ.5W5ohamRyEgAgFiVHh22
   [3] => flipod@otmail.co.uk
   [email] => flipod@otmail.co.uk
   [4] => 2013-01-05 20:52:53
   [join_date] => 2013-01-05 20:52:53
   [5] => 1
   [6] => Counter-Strike 1.6
   [game_id] => Counter-Strike 1.6
   [7] => singleplayer.dem
   [file_name] => singleplayer.dem
   [8] => DFDS
   [demo_name] => DFDS
   [9] => bvjjbkjb  c cgfc gvjhhj
   [demo_desc] => bvjjbkjb  c cgfc gvjhhj
   [10] => Ricciz0rz
   [uploaded_by] => Ricciz0rz
   [11] => 1359608484
   [upload_date] => 1359608484
)

 

Why am I getting the results twice? Is this normal?

 

Regards,

 

L2c.

Link to comment
https://forums.phpfreaks.com/topic/274466-mysqli_fetch_array/
Share on other sites

See mysqli_fetch_array in the manual

 

  Quote
... In addition to storing the data in the numeric indices of the result array, the mysqli_fetch_array() function can also store the data in associative indices, using the field names of the result set as keys.

 

The default is to return both. You can pass a parameter to specify one or the other. Or you can use mysqli_fetch_assoc or mysqli_fetch_row

Link to comment
https://forums.phpfreaks.com/topic/274466-mysqli_fetch_array/#findComment-1412357
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.