Codeigniter: Passing data from controller to view

后端 未结 13 2160
忘了有多久
忘了有多久 2020-11-27 06:57

I want to pass $data from the controller named poll to the results_view however I am getting an undefined variable error.

         


        
13条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 07:36

    In controller:

    public function product(){

    $data = array("title" => "Books", "status"=>"Read","author":"arshad","company":"3esofttech",
    

    "subject":"computer science");

    Data From Model to controller

    $this->load->model('bookModel');
    $result = $this->bookModel->getMoreDetailsOfBook();
    
    **Add *$result* from model to *$data* array**  
    $data['tableRows'] = $result;
    

    $data from Controller to View

    $this->load->view('admin/head',$data);
    

    And to access in view file views/user.php

    
    

提交回复
热议问题