CodeIgniter Forums

Full Version: Dropdown List from MySQL to HMTL <select>
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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);

El Forum

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

El Forum

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

El Forum

[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.