Codeigniter: Passing data from controller to view

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

    You just need to create a array, you using codeigniter right?

    Example on controller:

    $data['hello'] = "Hello, world";
    $this->load->view('results_view', $data);
    

    In de page "results_view" you just have to:

    
    

    Obs: You can create n datas, just pay attention in the name and make it a array.

    Obs²: To use the data use the key of the array with a echo.

提交回复
热议问题