Welcome Guest, Not a member yet? Register   Sign In
Passing a data array from model to controller and then finally to view
#1

[eluser]Unknown[/eluser]
Pretty basic stuff and probably have been asked a thousand times, but can't seem to find a simple answer about this.

This is an example of what I'm trying to do :

controller
Code:
$this->load->model('model_name', '', TRUE);
$data['something'] = $this->model_name->getAllSomethings();
$this->load->view('Index_view', $data);

model
Code:
function getAllSomethings()
{
  $query = $this->db->query("SELECT something FROM tblTable");

  foreach ($query->result_array() as $row)
  {
   return $row['something'];
  }
}
view
Code:
foreach ($something as $row)
{
  echo '$row['something'].'<br/>';
}

Obviously does not work.
How exactly do you send a data array and then echo everything out.


Messages In This Thread
Passing a data array from model to controller and then finally to view - by El Forum - 07-31-2012, 04:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB