我想呼应我此行的名单,当我试图print_r的值可以显示,但得到的数据,当我回应的结果总是PHP-笨如何在会议
消息:未定义的变量:冒险
文件名:视图/ profile.php
行号:121
回溯:
Severit Y:警告
消息:的foreach()
文件名提供参数无效:视图/ profile.php
行号:121
这是我的控制器:
public function getListTrip(){
$this->load->model('userModel');
$data['adventure'] = $this->userModel->getTrip()->result_array();
//echo ($data);
$this->load->view('profile', $data);
}
这是我的型号:
function getTrip(){
$userId = $this->session->userdata('user_id');
return $this->db->get_where('adventure',['user_id' => $userId]);
}
这是我的看法
<table>
<?php
foreach ($adventure as $b){
echo "<tr>
<td>$b->name</td>
<td>$b->place</td>
<td>$b->category</td>
</tr>";
}
?>
</table>
所以我应该如何修改我的代码,以使值显示在我的页面丝毫呼应或的foreach没有print_r的...非常感谢
提示你命名你的控制器错误的CI请点击此处阅读关于文件和类命名在CI https://www.codeigniter.com/user_guide/general/styleguide.html#file-naming – user4419336