我正在尝试使用CodeIgniter显示表格。我做了一个函数来从一个表中选择所有数据,并在单击按钮时使用 foreach 循环显示它。我收到此错误:
Fatal error: Call to undefined method CI_DB_mysql_driver::result() in C:\Xampp\htdocs\Auction\application\models\bidding_model.php on line 47
这是我的控制器页面:
public function viewauction()
{
$this->load->model('bidding_model');
$data['query'] = $this->bidding_model->viewauction();
$this->load->view('auction_view', $data);
}
这是模型:
function viewauction()
{
$query = $this->db->select('products');
return $query->result();
}
这是视图:
<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>