0
我試圖從數據庫得到news_id,但是當去查看說:錯誤 - >嘗試獲取非對象/消息的屬性:未定義的變量:數據試圖獲取非對象的屬性 - 未定義的變量:數據/ Codeigniter
這種模式 - >
class Model1 extends CI_Model {
public function get_art()
{
$query = $this->db->get('entries');
return $query->result();
}
}
這裏控制器代碼 - >
class Home extends CI_Controller
{
public function members()
{
$this->load->model('model1');
$data=$this->model1->get_art();
$this->load->view('members', $data);
}
}
這個完整視圖 - >
<html>
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
</head>
<body>
<h1>
<? echo $data->body; ?>
</h1>
</body>
</html>
非常感謝你 –