Display database table in CodeIgniter
34,385
Just change your model method code to
function viewauction()
{
$query = $this->db->select('*')->from('products')->get();
return $query->result();
}
Hope this helps. Thanks!!
Related videos on Youtube
Author by
user1733081
Updated on November 14, 2020Comments
-
user1733081 over 3 years
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>