I'm completely new to PHP and CodeIgniter and I'm trying to create a link in a view that, when clicked will return a list of data from a specific category.
vgs_model.php model
public function pcList(){
$this->db->select('*');
$this->db->from('videogame');
$this->db->where('Format', 'PC');
$query = $this->db->get();
return $query->result();
}
search.php controller
public function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('vgs_model');
}
public function index()
{
$this->load->view('header_view');
$this->load->view('search_view');
$this->load->view('footer_view');
}
public function getPc(){
$search_term = 'PC';
$data['results'] = $this->Vgs_model->pcList();
$this->load->view('search_results', $data);
}
search_view View
<a href = <?php echo site_url('Hello/getPc'); ?>>View PC Games</a>
I've been getting the following error
Message: Undefined property: Search::$Vgs_model
Filename: controllers/search.php
Line Number: 40
Line 40 is this
$data['results'] = $this->Vgs_model->pcList();
What am I doing wrong? Any help would be appreciated.
Thanks for reading my post.