I am trying to display a table using CodeIgniter. I made a function to select all data from one table and display it using a foreach loop when the button is clicked. I am getting this error:
Fatal error: Call to undefined method CI_DB_mysql_driver::result() in C:\Xampp\htdocs\Auction\application\models\bidding_model.php on line 47
This is my controller page:
public function viewauction()
{
$this->load->model('bidding_model');
$data['query'] = $this->bidding_model->viewauction();
$this->load->view('auction_view', $data);
}
This is the model:
function viewauction()
{
$query = $this->db->select('products');
return $query->result();
}
This is the view:
<tbody>
<?php foreach($query as $row): ?>
<tr>
<td><?php echo $row->product_id; ?></td>
<td><?php echo $row->auction_id; ?></td>
<td><?php echo $row->start_time; ?></td>
<td><?php echo $row->end_time; ?></td>
</tr>
<?php endforeach; ?>
</tbody>