Codeigniter: Passing data from controller to view

后端 未结 13 2128
忘了有多久
忘了有多久 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:14

    If you pass

    $data = your code
    $this->load->view('your-page', $data);
    

    and get data on your view as

    
    

    It won't work because ci didn't understand this patern. If like to pass value form controller to view so you can try this -

    controller -

    $data['any-name'] = your values;
    $this->load->view('your-page', $data);
    

    then in your view you can get this data by -

    
    

    Hope this helps you.

提交回复
热议问题