How to access a GET submission value via a CodeIgniter controller method
11:48 27 Jul 2015

I am very new to CodeIgniter and I am using  v2.2.3. I managed to create the following code but I am unable to display the data.

Here is my Model

db->where('id', $id);
        $query = $this->db->get('items');
        if($query->num_rows()!==0)
        {
            return $query->result();
        }
        else
            return FALSE;
   }
}
?>

Here is my Controller

  function item()
  {
        if($this->session->userdata('logged_in'))
        {          
            $data["results"] = $this->item_model->fetch_data($id);       
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];   
            $data['title'] = '';
            $this->load->view('inventory/item_view', $data);
         }
         else
         {
            $this->session->set_flashdata('message', 'Oops! You have to Login');
         //If no session, redirect to login page
            redirect('login', 'refresh');
         }
    }

I am unable to display data by getting the ID($id). It says that $id is undefined.

php codeigniter codeigniter-2 get-request