Welcome Guest, Not a member yet? Register   Sign In
me failing with $query->result()
#1

[eluser]devvee[/eluser]
Hi!

I think I have a fairly simple issue that I just can't seem to solve due to inexperience.

I have a model, a controller and a view. The controller loads the model and uses a function.

Code:
$this->load->model('Question_model', '', TRUE);
$data['query'] = $this->Question_model->get_open_questions();

The function inside the model performs a query (which I simplified, since that one isn't causing the problem) and returns the result.

Code:
$query = $this->CI->db->query("SELECT * FROM table");
return $query->result();

The query gets executed properly and even $query->result() doesn't cause any issues (I took this method straight from the model page in the user guide).

Now the results are in the controller in $data['query']. The controller now opens the view:

Code:
$this->load->view('home_view', $data);

Now my big question is.. how do I loop through the results on the view page? Of course "foreach($query->result() as $row):" won't work, because the result has already been returned and I'm quite clueless.

Thanks in advance Smile


Messages In This Thread
me failing with $query->result() - by El Forum - 05-07-2009, 08:08 AM
me failing with $query->result() - by El Forum - 05-07-2009, 08:13 AM
me failing with $query->result() - by El Forum - 05-07-2009, 08:15 AM
me failing with $query->result() - by El Forum - 05-07-2009, 10:08 AM
me failing with $query->result() - by El Forum - 05-07-2009, 10:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB