2

I have two functions in my model as

class Jobseeker_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
public function result_getall($id)
    {
        $this->db->select('*');    
        $this->db->from('tbl_jobseeker');
        $this->db->where('tbl_jobseeker.User_id',$id);
        $this->db->join('tbl_work_exp', 'tbl_jobseeker.User_id = tbl_work_exp.User_id','left');
    $query = $this->db->get();
return $query->row();
    }
    public function select($id) 
    {   
        $this->db->select('*'); 
        $this->db->from('tbl_qualification');
        $this->db->where('tbl_qualification.User_id',$id);
        $query = $this->db->get();
        return $query->result();

    }
}

And in my controller I have a function as

public function display()
    {
      $id = $this->session->userdata('user_id');
      $data['row'] = $this->jobseeker_model->result_getall($id);
      $res['a'] = $this->jobseeker_model->select($id);
      $this->load->view('jobseeker_display.php', $data,$res);
}

It is not possible to display the view page.. I could pass two variables into my view page.right?

1

3 Answers 3

4

You can pass your any number of variables/arrays using a single array. In Controller:

public function display() {
      $id = $this->session->userdata('user_id');
      $data['var1'] = $this->jobseeker_model->result_getall($id);
      $data['var2'] = $this->jobseeker_model->select($id);
      $this->load->view('jobseeker_display.php', $data);
}

In View:

`$var1` and `$var2` will be available.
Sign up to request clarification or add additional context in comments.

Comments

1

You can pass your two variable using single srray

public function display()
    {
      $id = $this->session->userdata('user_id');
      $data['row'] = $this->jobseeker_model->result_getall($id);
      $data['a'] = $this->jobseeker_model->select($id);
      $this->load->view('jobseeker_display.php', $data);
     }

Views

foreach($a as $data){
// your code
}

echo $row->column_name;

Comments

1

Try this

public function display()
    {
      $id = $this->session->userdata('user_id');
      $data['row'] = $this->jobseeker_model->result_getall($id);
      $data['a'] = $this->jobseeker_model->select($id);
      $this->load->view('jobseeker_display.php', $data);
}

1 Comment

If you want $res then use this, $data['res']['a'] = $this->jobseeker_model->select($id);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.