我想呼應我在查看數據庫的領域,但我得到的錯誤:迴盪在視圖頁
Message: Trying to get property of non-object
Filename: views/admin_view_report.php
Line Number: 7
當我呼應了整個陣列,它工作得很好。我找不到有什麼問題。我的控制器的
部分:
function index(){
$this->load->model('viewreport');
$data['records']=$this->viewreport->getAllByChk();
$this->load->view('admin_view_report',$data);
}
我的模型的一部分:
function getAllByChk(){
$q = $this->db->get('info');
if ($q->num_rows()>0){
foreach ($q->result_array() as $row)
{
$data[]=$row;
}
return $data;
}
}
的觀點:
<?php foreach($records as $row):?>
<?php echo $row->subject; ?>
<?php endforeach;?>
如果我只打印data['records']
它提供了以下輸出
Array
(
[0] => Array
(
[id] => 1
[address] => 11/siddeshwari
[area] => sid
[lat] => 21
[lng] => 21
[subject] => hello
[problem] => lots of problem
[image] =>
[time] => 2011-08-11 23:49:29
[register_id] => 1
[category_id] => 1
[city_city_id] => 1
[status_status_id] => 0
)
[1] => Array
(
[id] => 2
[address] => 134 banani
[area] => banai
[lat] => 1223
[lng] => 2133
[subject] => not working
[problem] => yesproblem problem problem
[image] =>
[time] => 2011-08-12 01:09:44
[register_id] => 1
[category_id] => 2
[city_city_id] => 1
[status_status_id] => 0
)
)
但是當我嘗試打印問題或主題只有它給出了錯誤。
你能改變<?php echo $ row-> subject; ?>到<?php print_r($ row); ?>並向我們顯示輸出? – mattumotu
輸出上面給出 – tan