Welcome Guest, Not a member yet? Register   Sign In
foreach outputting array?
#3

[eluser]osci[/eluser]
in your model

Code:
function get_combo()
{
   $query = $this->db->from('table')->select('id, displayfield')->get();

   if($query->num_rows() > 0) {
   foreach ($query->result() as $row) {
      $data[$row->id] = $row->displayfield;
   }
   return $data;
   }
}

in your controiller
Code:
//......
$data['rs_combo'] = $this->your_model->get_combo();
$this->load->view('view', $data);

in your view

Code:
<?php echo form_dropdown('name', $rs_combo); ?>


Messages In This Thread
foreach outputting array? - by El Forum - 05-15-2011, 10:57 PM
foreach outputting array? - by El Forum - 05-16-2011, 01:01 AM
foreach outputting array? - by El Forum - 05-16-2011, 01:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB