我想從我的控制器傳遞到像這樣的觀點...笨將數據傳遞給視圖
public function playerslist()
{
$this->load->database();
$data = $this->db->get('skaters');
$this->load->helper('url');
$this->load->view('playerslist', $data);
}
在我看來......
<?php echo $data; ?>
,但我得到這個錯誤...
遇到一個PHP錯誤
嚴重性:注意
消息:未定義的變量:數據
文件名:觀點/ playerslist.php
行號:76
我在做什麼錯?
我想這樣做與此數據被放在一個foreach語句和$數據數組中顯示一切
foreach($data as $value => $key){
echo $key . "<br/>";
}
感謝, Ĵ
的[笨從控制器傳遞數據,以查看]可能重複(http://stackoverflow.com/questions/6257736/codeigniter-passing-data -from-controller-to-view) –