GSP Posted January 29, 2010 Share Posted January 29, 2010 In my database, I have five fields: id, name, option1, option2, and option3. When I query the database and print_r the array, I get: Array ( [0] => 4 [id] => 4 [1] => carley [name] => carley [2] => no [option1] => no [3] => no [option2] => no [4] => yes [option3] => yes ) Why is it that each field gets a separate name and reprint the value? How do I get it to look like this?: Array ( [id] => 4 [name] => carley [option1] => no [option2] => no [option3] => yes ) Link to comment https://forums.phpfreaks.com/topic/190265-why-does-my-query-array-look-like-this/ Share on other sites More sharing options...
akitchin Posted January 29, 2010 Share Posted January 29, 2010 the manual offers the answer: mysql_fetch_array the function will return an array with both numerical and string indexes for each column. use the optional $result_type flag to restrict it to one type or the other. Link to comment https://forums.phpfreaks.com/topic/190265-why-does-my-query-array-look-like-this/#findComment-1003810 Share on other sites More sharing options...
GSP Posted January 29, 2010 Author Share Posted January 29, 2010 the manual offers the answer: mysql_fetch_array the function will return an array with both numerical and string indexes for each column. use the optional $result_type flag to restrict it to one type or the other. Doh! Thanks! Link to comment https://forums.phpfreaks.com/topic/190265-why-does-my-query-array-look-like-this/#findComment-1003822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.