Here is my Model:
function get_name() {
$this->db->select('first_name');
$this->db->where('email', $this->session->userdata('email'));
$query = $this->db->get('users');
if($query->num_rows() == 1) {
return true;
}
}
and this is my controller method:
function show_name() {
$this->load->model('users_model');
$this->users_model->get_name();
}
and the method that passes a name to view:
function profile(){
$data['first_name'] = $this->show_name();
$this->load->view('members/template', $data);
}
I get nothing in the view, I checked my query and it works fine. Is there anything I’m missing?
You need to update your code. You need to return
first_namefrom the functionget_nameYou also need to
returnthe value from functionshow_name