【发布时间】:2021-10-15 15:34:37
【问题描述】:
我需要有关 Codeigniter 分页、排序和过滤的帮助。我的问题是我正在过滤产品,但是当我单击下一步按钮时,它全部重置。我想用 get 方法对过滤的分页。这是我的代码; 控制器:
$config = array();
$config["base_url"] = base_url() . "ilanlar";
$config["total_rows"] = $this->ilan_model->get_count($posted_items);
$config["per_page"] = 10;
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["links"] = $this->pagination->create_links();
$data["row"] = $this->product_model->get_row($posted_items);
$data['products'] = $this->product_model->get_products($config["per_page"], $page);
$data['get'] = $_GET;
$this->load->view('pages/product/product', $data);
型号
$this->db->limit($limit, $start);
$this->db->order_by('id', 'DESC');
$this->db->where('status',2);
if(!empty($get['min'])){
$this->db->where('ad_price>='.$get['min']);
}
if(!empty($get['max'])) {
$this->db->where('ad_price<=' .$get['max']);
}
$query = $this->db->get('ad_table');
return $query->result();
我的网址一定是这样的。
myapp.com/list/0?min=50&max=300
但是当我点击下一页时它会改变 myapp.com/list/10
已经谢谢你们了。
【问题讨论】:
标签: php sorting codeigniter filter pagination