Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter : displaying query result in controller

I am trying to display my db query result in my controller, but I don't know how to do it. could you please show me?

Controller

 function get_name($id){

 $this->load->model('mod_names');
 $data['records']=$this->mod_names->profile($id);

// I want to display the the query result here 
 // like this:  echo $row ['full_name'];

 }

My Model

function profile($id)
    {  

        $this->db->select('*');
        $this->db->from('names');
        $this->db->where('id', $id); 
        $query = $this->db->get();


        if ($query->num_rows() > 0)
        { return $query->row_array();
        }
        else {return NULL;}

    }   
like image 203
black_belt Avatar asked Dec 12 '22 02:12

black_belt


1 Answers

echo '<pre>';
print_r($data['records']);

or

 echo $data['records'][0]['fullname'];
like image 105
Muhammad Raheel Avatar answered Jan 05 '23 10:01

Muhammad Raheel