我正在学习Codeigniter MVC框架。在尝试运行一个简单的程序时,我收到与View中的foreach循环相关的错误。有人可以帮帮我吗?
class HomeController2 extends CI_Controller
{
public function index(){
$this->load->model('HomeModel2');
$data['record']=$this->HomeModel2->getdata();
$this->load->view('HomeView2',$data);
}
}
class HomeModel2 extends CI_Model
{
public function getdata(){
$query=$this->db->get('studen');
return $query->result();
}
}
foreach ($record as $ray) {
echo $ray->ID." ".$ray->NAME" ";
}