Welcome Guest, Not a member yet? Register   Sign In
passing data from a controller to my view
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter community!

$this should be avoided within views if you can. Rather than doing the foreach in the controller, why not do it in the model and have the model format the data exactly how you need it?

Code:
function get_band($id)
{
    $this->db->where('id', $id);
    $result = $this->db->get('bands');
    return $result->result_array();
}

Or you could do something like this in your controller:
Code:
$data['query'] = $this->form_model->get_band($id);
$data['query'] = $data['query']->result_array(); # PHP 4

#OR

$data['query'] = $this->form_model->get_band($id)->result_array(); # PHP 5


Messages In This Thread
passing data from a controller to my view - by El Forum - 03-10-2009, 09:51 AM
passing data from a controller to my view - by El Forum - 03-10-2009, 10:02 AM
passing data from a controller to my view - by El Forum - 03-10-2009, 10:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB