Welcome Guest, Not a member yet? Register   Sign In
Displaying all array values in a view. foreach not working for some reason.
#1

[eluser]jtotheb[/eluser]
i have a model:

Code:
function contact_values()
{
  $query = $this->db->get('column_data');
  
  foreach($query->result_array() as $col_list)
  {
   return $col_list;
  }
}

I have a controller:

Code:
function index()
{
  $this->load->model('Testmodel');
  $data['con_options']= $this->Testmodel->contact_values();
  $this->load->view('selection', $data);
}

And i have a view:

Code:
<ul>
&lt;?php foreach($con_options as $item):?&gt;
<li>&lt;?=$item;?&gt;</li>
&lt;?php endforeach;?&gt;
</ul>

And it only shows the first value in the view.

Can anyone tell me where i'm going wrong?

I think it must be in the controller, that i'm not passing the model result as an array properly to the $data array.

If anyone can help i would be very grateful.

Thanks.


Messages In This Thread
Displaying all array values in a view. foreach not working for some reason. - by El Forum - 07-24-2007, 04:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB