![]() |
Result Set directly pass to dropdown - 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: Result Set directly pass to dropdown (/showthread.php?tid=53134) |
Result Set directly pass to dropdown - El Forum - 07-12-2012 [eluser]abhinavp[/eluser] Hello There, I need to know is there any way in Codeigniter in which we can pass database result set directly to form_dropdown function. Please let me know, if there is any way to do this task. Thanks Result Set directly pass to dropdown - El Forum - 07-12-2012 [eluser]guzzilar[/eluser] Code: foreach($query->result() as $item): Try this. ![]() Result Set directly pass to dropdown - El Forum - 07-12-2012 [eluser]CroNiX[/eluser] No there isn't. You'd have to do what guzzilar suggested, or create a helper to do it since this is a very common thing and you will probably use it many times. Code: function array_to_dropdown($raw_data, $key_field, $value_field) Usage: Code: $values = $this->db |