Home > Mobile >  I can't pass the data from the controller to the view in CodeIgniter 3
I can't pass the data from the controller to the view in CodeIgniter 3

Time:12-01

I can't pass the data from the controller to the view in CodeIgniter 3. All the thing seem okay. Do I need to put the Controller's part in the index() method?

Donor_Model.php

function viewDonors() {
        $query = $this->db->get('donors');
        return $query;
    }

Staff.php controller

public function viewDonors()
    {

        $this->load->Model('Donor_Model');
        $data['donors'] = $this->Donor_Model->viewDonors();
        $this->load->view('viewdonors', $data);
    }

When I try to call the $data in the viewdonors.php view, it shows the $donors as undefined.

screenshot of viewdonors.php

CodePudding user response:

@TimBrownlaw is right. Even though the IDE shows an error, the code runs without a problem.

  • Related