i want to make pagination but it is not working properly i have a function with the name of product for this,on first page its shows me products and links when i clicks on link2 then it shows me an empty page. when i make one more function with the name pagination having same code and different route then its working but just shows me product on other pages but the other links like previous links and header footer links are not working, so i just wanted to use only one function for pagination.
My controller
public function product()
{
$data = array();
$data['about'] = $this->Adminlogin_model->get_all_about();
$data['get_all_category'] = $this->web_model->get_all_category();
$data['get_all_subcategory'] = $this->Seller_Model->get_subcats_header();
//filter-start
$scat_id=$_GET['scat_id'];
$cat_id=$_GET['cat_id'];
$data['get_subcategory_byid'] = $this->db->WHERE('cat_id',$_GET['cat_id'] )->get("tbl_subcategory")->result();
$data['cat_id'] = $_GET['cat_id'];
$data['get_category_byid'] = $this->db->WHERE('id', $_GET['cat_id'])->get("tbl_category")->result();
//end-filter
if (!empty($_GET['cat_id']) || !empty($_GET['scat_id']) != "") {
// $data['search_item'] = $this->Seller_Model->product($_GET);
$config = array();
$scat_id=$_GET['scat_id'];
$cat_id=$_GET['cat_id'];
// $where = array('cat_id'=>$cat_id,'scat_id'=>$scat_id);
// $config['page_query_string'] = TRUE;
$config["base_url"] = base_url('') . "paginationsubcat/".$scat_id.'/'.$cat_id;
$config["total_rows"] = $this->Seller_Model->get_count($cat_id);
$config["per_page"] = 4;
$config["uri_segment"] = 4;
// print_r($this->uri->segment(1));
//die;
$config['num_links'] = 2;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$config['first_tag_open'] = '<li class="page-item"><span class="page-link">';
$config['first_tag_close'] = '</span></li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="page-item"><span class="page-link">';
$config['prev_tag_close'] = '</span></li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li class="page-item"><span class="page-link">';
$config['next_tag_close'] = '</span></li>';
$config['last_tag_open'] = '<li class="page-item"><span class="page-link">';
$config['last_tag_close'] = '</span></li>';
$config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page-item"><span class="page-link">';
$config['num_tag_close'] = '</span></li>';
$this->pagination->initialize($config);
// $data['search_item'] = $this->Seller_Model->pagination($config['per_page'],$this->uri->segment(3));
$data['search_item'] = $this->Seller_Model->product($_GET,$config['per_page'],$this->uri->segment(4));
// $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["links"] = $this->pagination->create_links();
$this->load->view('all_products', $data);
} else {
$this->content_errors();
}
}
my model
public function product($data,$limit,$offset){
$this->db->select('*');
$this->db->from('tbl_slr_ad');
// $this->db->like('scat_id',$scat_id);
$this->db->where($data);
$this->db->limit($limit,$offset);
$info = $this->db->get();
return $info->result();
}
Route
$route['subcat'] = "Seller_Controller/product";