Im trying to populate 3 tables in the view by passing 3 different arrays from the controller to the view (which get data from the database). But I get an error as
Fatal error: Call to undefined method stdClass::result_array() in C:\xampp\htdocs\SEP\application\views\ManagerViewProjectDatabase.php on line 39
The controller method is as
function ManagerProjects()
{
$this->load->model('ViewProjectsModel');
$new=$this->ViewProjectsModel->ManagerViewProjects('new');
$ongoing=$this->ViewProjectsModel->ManagerViewProjects('inprogress');
$completed=$this->ViewProjectsModel->ManagerViewProjects('completed');
$data=array('new'=>$new, 'inprogress'=> $ongoing,'completed'=>$completed);
$this->username=$this->session->userdata('username');
$this->DashBoardMainView($this->username);
$this->load->view('ManagerViewProjectDatabase',$data);
}
the model class function is as
function ManagerViewProjects($status)
{
$this->db->select('*');
$this->db->from('project');
$this->db->where('status',$status);
$query=$this->db->get();
$q1=$query->row();
return $q1;
}
and the view is as
<tbody>
<?php foreach ($new->result_array() as $row): ?>
<tr>
<td><?php echo $row['project_id'];?></td>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['start_date'];?></td>
<td><?php echo $row['deadline'];?></td>
<td><?php echo $row['description'];?></td>
<td><?php echo $row['language'];?></td>
<td><?php echo $row['framework'];?></td>
</tr>
<?php endforeach; ?>
</tbody>
ManagerViewProjectDatabase Line 39 is the beginning of the foreach.
Im new to code igniter so Im not sure what goes on here with the error. Please point me in the right direction. Thanks in advance