【发布时间】:2018-05-25 02:07:40
【问题描述】:
我是这里的新用户。我正在尝试为 CRM 系统创建一个带有搜索过滤器的简单分页。有五个过滤器选项用于搜索和显示记录。我想要每页 100 条记录,并且我的过滤器选项在第一页上运行良好。问题是当我单击下一页或第二页以显示搜索数据的下 100 条记录时,它正在重置所有过滤器值并显示 100 条记录,我无需选择任何过滤器值即可获得这些记录。我正在寻找这个问题的解决方案,以便我可以根据给定的过滤器值获取下一页。
下面我给出了我的控制器和视图页面的分页部分,
Controller page
if (!isset($_GET['page']) or !is_numeric($_GET['page'])) {
$page = 0;
} else {
$page = (int)$_GET['page'];
}
$customerslist = array();
$customers = $db->query("select cu.email, cu.notinterested, cu.version, cu.autoresponder, cu.customer_support, cu.verified, cu.verified_date, cu.customer_id, cu.customer_name, cu.address, cu.telephone_no, cu.email, cu.person_incharge, cu.designation, ct.city_name, st.state_name, emp.username from customers as cu left join state as st on st.id = cu.state left join city as ct on ct.id = cu.city left join tbllogin as emp on emp.employee_id = cu.customer_support
where cu.customer_name!='' and cu.customer_support>0 and cu.company_id='".$cid."' ".$cont." ".$order_by." limit ".$page.",100");
foreach($customers->fetchAll() as $cl) {
$customerslist[] = $cl;
}
view page
<?php
$nextt = $page + 100;
if ($sno > 100)
echo '<a href="?controller=customers&action=index&cid='.$cid.'&page='.$nextt.'"><b>Next<b></a>';
$prev = $page - 100;
?> <?php
if ($prev >= 0)
echo '<a href="?controller=customers&action=index&cid='.$cid.'&page='.$prev.'"><b>Previous<b></a>';
?>
【问题讨论】:
-
您需要将所有搜索参数传递给分页链接
-
能否详细解释一下?
-
在搜索中给我你的 GET 参数列表
-
$customer_name = $_POST['customer_name']; $state_id = $_POST['state_id']; $customer_action = $_POST['customer_action']; $customer_support = $_POST['customer_support']; $versions = $_POST['version_id']; $test = $_POST['test']; $email = $_POST['emailoption'];
标签: php