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
Share on other sites

See mysqli_fetch_array in the manual

 

... 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.