Welcome Guest, Not a member yet? Register   Sign In
Trying to get property of non object

I am using the model method called content ($this->model_admin->content($limit, offset) to get data. I want to access each of the data from the model method individually inside the controller, but it gives me an error when trying to do it.

I am not sure if I am correctly accessing the object, e.g. $db4->first_name (is this correct or do I need a foreach loop first???)

function ajax_employees($offset = 0)

   $config['base_url'] = site_url('admin/ajax_employees/');
   /* Here i am indicating to the url from where the pagination links and the table section will be fetched */

   $limit = 3;

   $config['div'] = '#content';
   /* CSS selector  for the AJAX content */
   $config['total_rows'] = $this->model_admin->num_rows();
   $config['per_page'] = $limit;

   $tmpl = array ( 'table_open'  => '<table border="0" cellpadding="2" cellspacing="1" width="100%" class="main_awesome_row">',
       'heading_cell_start'  => '<th class="main_awesome_header">',
       'heading_cell_end'    => '</th>',


   $this->table->set_heading('ID', 'First Name', 'Surname', 'Email','Other','Job Title','Department','Select');
   $db4 = $this->model_admin->content($limit, $offset);
   $list = array($db4->first_name, 'Select');

   $new_list = $this->table->make_columns($list, 8);
   $html = $this->table->generate($new_list).
   '<div align="center"><br/><span class="pagination">'.$this->jquery_pagination->create_links().'</span></div>';

   echo $html;


function num_rows() {
   return $this->db->count_all('employees');

  function content( $limit, $offset ) {
    $this->db->select('id, first_name,last_name, email, other, job_title,department');
    $result = $this->db->get('employees', $limit, $offset);
    return $result->result_array();

Theme © iAndrew 2016 - Forum software by © MyBB