Php 带索引功能的CodeIgniter分页
我有一个产品列表,当我按下子类别时,它会加载该子类别中的所有产品,并使用索引作为:Php 带索引功能的CodeIgniter分页,php,html,codeigniter,pagination,Php,Html,Codeigniter,Pagination,我有一个产品列表,当我按下子类别时,它会加载该子类别中的所有产品,并使用索引作为: http://localhost/ClickBasket/listproductscontroller/index?subcategory=4 因为它可以包含很多产品,所以我使用了CI的分页库。当我转到第二页或第三页时,它运行良好: http://localhost/ClickBasket/listproductscontroller/index/1?subcategory=4 http://localhost
http://localhost/ClickBasket/listproductscontroller/index?subcategory=4
因为它可以包含很多产品,所以我使用了CI的分页库。当我转到第二页或第三页时,它运行良好:
http://localhost/ClickBasket/listproductscontroller/index/1?subcategory=4
http://localhost/ClickBasket/listproductscontroller/index/2?subcategory=4
但当我返回到第一页时,它将丢失子类别的id:
http://localhost/ClickBasket/listproductscontroller/index
因此,在页面中找不到子类别及其产品的数据。你怎么解决这个问题?我仍在学习CodeIgniter的分页库 试试看
我的代码:
//pagination
$this->load->library('pagination');
$config['base_url'] = site_url('/ClickBasket/listproductscontroller/index');
$config['total_rows'] = $this->db->query('SELECT FOUND_ROWS() count;')->row()->count;
$config['per_page'] = 9;
#$config['uri_segment'] = 4;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] = "</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['page_query_string'] = true;
$config['query_string_segment'] = 'page';
$config['reuse_query_string'] = true;
$config['use_page_numbers'] = true;
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
//分页
$this->load->library('pagination');
$config['base_url']=site_url('/ClickBasket/listproductscontroller/index');
$config['total_rows']=$this->db->query('SELECT FOUND_rows()count;')->row()->count;
$config['per_page']=9;
#$config['uri_segment']=4;
$config['full_tag_open']=“”;
$config['full_tag_close']=“
”;
$config['num_tag_open']='';
$config['num_tag_close']=' ;
$config['cur\u tag\u open']=“”;
$config['next_tag_open']=“”;
$config['next_tagl_close']=“ ”;
$config['prev_tag_open']=“”;
$config['prev_tagl_close']=“ ”;
$config['first_tag_open']=“”;
$config['first_tagl_close']=“ ”;
$config['last_tag_open']=“”;
$config['page\u query\u string']=true;
$config['query_string_segment']='page';
$config['reuse\u query\u string']=true;
$config['use_page_number']=true;
$config['last_tagl_close']=“ ”;
$this->pagination->initialize($config);
您能分享一下您的控制器逻辑吗?你可以在管制员那里处理谢谢你!但我唯一真正缺少的是“重用查询字符串”配置。