Welcome Guest, Not a member yet? Register   Sign In
loading the results of a foreach
#2

[eluser]Pascal Kriete[/eluser]
You need to return something to the controller. Right now you're just echoing (adding to the browser output).

You could return the result set if you have results:
Code:
function retrieve_members()
{
    $query = $this->db->query('SELECT id, firstName, lastName, memberNum, email FROM member');
    return ($query->num_rows() > 0) ? $query->result() : FALSE;
}

I prefer just returning the $query object, but let's use the above example - the controller could be:
Code:
$data['members'] = $this->CMS_model->retrieve_members();    
$this->load->view('template', $data);

And then loop through $members in the view and show the details (or do whatever you need to with the data, I obviously don't know where this is going).

Hope that helps.
Welcome to CodeIgniter.


Messages In This Thread
loading the results of a foreach - by El Forum - 01-30-2009, 06:22 PM
loading the results of a foreach - by El Forum - 01-30-2009, 06:31 PM
loading the results of a foreach - by El Forum - 01-30-2009, 06:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB