OK so I'm quickly making my way through codeigniter...
It seems pretty pleasant and the MVC model seems Okay.
But I have come accross a problem in passing an array to a view and displaying it.
Following the MVC pattern, the database queries are separated into the Model file. [Good.]
The HTML is for the view and the controller kinda does all the trafficing.
So my db code for the controller is as follows:
$this->load->model('Site_model');
$mya = $this->Site_model->getAll();
//load the view
$this->load->view('database',$mya);
foreach ($mya->result() as $row) {
echo $row->post_date;
//echo '<br>';
}
And when I print the foreach statement within the CONTROLLER it works fine.
But the problem is in the view:
I would think the following would work
<html>
<head>
<title>db web page</title>
</head>
<body>
<p> <h1>
<?php
foreach ($mya->result() as $row) {
echo $row->post_date;
//echo '<br>';
}
?>
</p></h1>
</body>
</html>
Does it fook? It complains about an undefined variable mya?!
But I just passed it that? What am I doing wrong.