Welcome Guest, Not a member yet? Register   Sign In
Assign data to view
#1

[eluser]Unknown[/eluser]
Hi all,

New here so, hello!

Just started using codeIgniter and I'm very excited by it. Just reading the user guide.

I created a controller which connects to a db (I know db stuff can go in a model) and pulls in some records. I also have a view for this controller.

My question is how do I loop over the results and then generate the rows in the view?

I know I can push an array of data to the view like so:

$this->load->view('myview', $data);

and then loop over this in the view...

...but how do I add data to the array as I loop over the db table in the for each

foreach ($query->result() as $row)
{
//Assign the $data variable here
}




Theme © iAndrew 2016 - Forum software by © MyBB