Codeigniter视图执行期间出错

时间:2017-04-16 08:22:51

标签: php codeigniter codeigniter-3

我正在学习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" ";
}

0 个答案:

没有答案