user1733081 user1733081 - 1 year ago 75
MySQL Question

display database table in codeigniter

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()

$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

<?php foreach($query as $row): ?>

<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>

<?php endforeach; ?>


Answer Source

Just change your model method code to

function viewauction()
    $query = $this->db->select('*')->from('products')->get();
    return $query->result();

Hope this helps. Thanks!!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download