Love2c0de Posted February 14, 2013 Share Posted February 14, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274466-mysqli_fetch_array/ Share on other sites More sharing options...
DavidAM Posted February 14, 2013 Share Posted February 14, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/274466-mysqli_fetch_array/#findComment-1412357 Share on other sites More sharing options...
Love2c0de Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) Just changed it to mysqli_fetch_assoc and I'm getting exactly what I want. Thanks very much! Regards, L2c. Edited February 14, 2013 by Love2c0de Quote Link to comment https://forums.phpfreaks.com/topic/274466-mysqli_fetch_array/#findComment-1412360 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.