【发布时间】:2017-09-29 10:47:30
【问题描述】:
我想回显我的行程列表,当我尝试 print_r 时,值可以显示,但当我总是回显结果时
消息:未定义变量:冒险
文件名:views/profile.php
行号:121
回溯:
严重性:警告
消息:为 foreach() 提供的参数无效
文件名:views/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>
那么我应该如何编辑我的代码以使值显示在我的页面中,而 echo 或 foreach 不在 print_r 中...非常感谢
【问题讨论】:
-
提示您将控制器命名为错误的 CI 请在此处阅读有关 CI codeigniter.com/user_guide/general/styleguide.html#file-naming 中的文件和类命名的信息
标签: php codeigniter session