CodeIgniter Forums
Dropdown List from MySQL to HMTL <select> - 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: Dropdown List from MySQL to HMTL <select> (/showthread.php?tid=56611)



Dropdown List from MySQL to HMTL <select> - El Forum - 01-07-2013

[eluser]cPage[/eluser]
//-- MODEL
Code:
function select_list($string)
{
  $q = $this->db->query('SELECT '.$string.' FROM '.$this->table);
  return $q->result_array();
}
//-- CONTROLLER
Code:
$data['myListClient'] = $this->client_model->select_list('id_client,client');
//-- VIEW
Code:
foreach( $myListClient as $row )
{
   $dd[$row['id_client']] = $row['client'];
}
echo form_dropdown('lstClient', $dd);



Dropdown List from MySQL to HMTL <select> - El Forum - 01-07-2013

[eluser]jprateragg[/eluser]
Did you have a question???


Dropdown List from MySQL to HMTL <select> - El Forum - 01-07-2013

[eluser]cPage[/eluser]
How can i have 2 columns per row inside the dropdown control ? I mean on the same level .


Dropdown List from MySQL to HMTL <select> - El Forum - 01-07-2013

[eluser]CroNiX[/eluser]
You'd have to use CSS, and the form_dropdown() function doesn't allow you to customize the output, so you'd have to do it manually.