我無法在視圖中訪問codeigniter控制器數組值。我在哪裏錯過。如何通過Codeigniter控制器數組來查看和使用foreach函數?
爲MyModel
function get_data(){
$this->db->select('prod_id, content, details');
$query = $this->db->get('tblesample');
return $query->result();
}
控制器
public function index(){
$this->load->model('mymodel');
$user_info = $this->mymodel->get_data();
$this->load->view('inc/header_view');
$this->load->view('data_view', $user_info);
}
data_view
<div class="col-md-9">
<?php
foreach ($user_info as $info) {
echo $info->content;
}
?>
</div>