分页实现后,通过多条件查询后,内容如果需要分页,容易出现切换页面内容跳转到查询前的内容。解决方法可以通过将查询后的内容建表,然后在进行分页。
<?php require_once "../wenjian/DBDA.class.php"; require_once "../wenjian/page.class.php"; // $obj = "select * from book WHERE is_delete= ‘0‘ "; $obj = "select * from book,gp WHERE book.is_delete= ‘0‘ and gp.gp_name = book.group_name "; if (!empty($_GET)){ $obj .= !empty($_GET[‘shu‘])?" and book_name like ‘%{$_GET[‘shu‘]}%‘ ":""; $obj .= !empty($_GET[‘zuozhe‘])?" and writer_name like ‘%{$_GET[‘zuozhe‘]}%‘ ":""; $obj .= !empty($_GET[‘fen‘])?" and group_name like ‘%{$_GET[‘fen‘]}%‘ ":""; } //将查询内容重新建表 $table = "(".$obj.") as t "; $obj = "select * from $table WHERE is_delete= ‘0‘ "; // echo $obj; $db = new DBDA(); $zts = "select count(*) from $table WHERE is_delete=‘0‘"; $count = $db->StrQuery($zts); $page = new Page($count,2); $obj .= $page->limit; $data = $db->Query($obj);
时间: 2024-10-13 15:03:52