![]() |
How do i convert a query result into an associative array? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How do i convert a query result into an associative array? (/showthread.php?tid=45779) |
How do i convert a query result into an associative array? - El Forum - 10-05-2011 [eluser]zulubanslee[/eluser] I need to pass an associative array to form_dropdown(), but I don't know how to convert. I've tried this in my model. Code: $query = $this->db->query("SELECT id, category FROM categories WHERE id = '$id'"); and Code: foreach($query->result() as $row) http://imgur.com/hrZOf&MkPKD; The bold numbers are the soft indexing apparently and the numbers above the words are the values of the options. Naturally I only want the words to show up in the menu. Here is what I have in my Controller Code: $queries['category_array'] = $this->categorymodel->getcategories(); |