【发布时间】:2014-12-12 17:39:04
【问题描述】:
所以我有一个列出销售线索的页面,这个页面有一个过滤表单,用户提交过滤列表,以便它只显示他们选择的数据(作为过滤条件),它也有分页,每当我使用分页(如单击其中一个链接)然后使用过滤器,过滤器不起作用,我觉得问题出在分页的 base_url 配置或 uri_segment 中,就像我发布过滤器数据时一样应该调用一个函数(过滤器),它显然将最后一个 uri 段从“列表”更改为“过滤器”,当我不使用分页时会发生这种情况,但是当我使用它然后使用过滤器时,它只是附加了“过滤器” ' 到最后,所以我最终得到了不正确的 'lists/filter',我该如何解决这个问题? :s 我已经尝试删除/更改 uri_segment,无论如何我可以修改分页配置的 base_url 变量以允许它工作吗? 另外,当我点击任何不是第一页的链接时,结果的数量会显示在我的 uri 中,这会影响什么吗?
相关代码: 控制器:
public function lists($offset = 0) {
$this->load->library('pagination');
$limit = 13;
$this->load->model('listsalemod'); //load the model that contains the database functionality.
$lead = $this->listsalemod->listlead($limit, $offset); //load the function that lists leads and pass it to a variable
$cli = $this->listsalemod->listcli(); //load the function that lists clents and pass it to a variable
$data = array(); //create an array
$data['lead'] = $lead['records']; //pass lead data to array
$data['cli'] = $cli; //pass client data to array
$config['base_url'] = site_url('list_sales/lists');
$config['total_rows'] = $lead['count'];
$config['per_page'] = 13;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$this->load->library('pagination');
$data['pagination'] = $this->pagination->create_links();
$this->load->view('list_sales', $data); //load the view and pass in the data.
查看:
<body>
<div id="container">
<form method="post" action="filter">
BFstaff <input type=text name="staff">
date: <input type=text name="date">
Client <input type=text name="client">
<input type="submit" value="submit">
</form>
<table id="table">
<tr>
<th>short description</th>
<th>Client</th>
<th>Created</th>
<th>view</th>
<div id="pagination">
<?php
echo $pagination;
?>
提前谢谢你。
【问题讨论】:
标签: php codeigniter pagination