Reputation: 140
I'm unable to view data from my database using these codes. Just echoing NO Records Returned
controller :
public function get_task()
{
$data = array();
if( $query = $this->model_users->getTask()){
$data ['records'] = $query ;
}
$this->load->view('Reg_Login/members', $data);
}
members.php :
<?php if(isset($records)) : foreach($records as $row): ?>
<tr>
<td><?php echo $row->tname ;?></td>
<td><?php echo $row->time; ?> </td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<h2>No Records Returned</h2>
<?php endif; ?>
model_users :
public function getTask()
{
$query = $this->db->get('tasks');
return $query->result();
}
Upvotes: 0
Views: 125
Reputation: 140
There was no error in the code.
By using $this->output->enable_profiler(TRUE);
in my controller
I found that, I just didn't invoke my method
properly.
That's all, you can use these codes to fetch data from DB
and show in your view file
.
Upvotes: 1