I have controller and view and I have very noob question, how to pass the data to view.
if (is_int($page)){
$this->load->model("Gamesmodel");
$query = $this->Gamesmodel->games("all",$page);
$this->load->view("games", $query);
}
and view
<?php
if ($query->num_rows() > 0)
{
foreach ($query->result as $row)
{
echo $query->result->title;
}
}
?>
A few things.
1) You need to pass an array or an object to the view with the variables set as keys (if using an array) or attributes (if using an object). i.e.
2)
resultis a method, not an attribute, so you need to call it as such.3) You need to call the
$rowvariable inside of your loop, not the$queryvar you are looping through.So, now you should have code something like this:
in the controller:
in the view: