因为用thinkphp做分页时候点击下一页后搜索栏的数据会清空,然后点击下一页后刷新完了就没有内容了,感觉网上查找和我自己研究在不适用ajax做分页的情况下用以下代码就可以实现!!通过把值扔地址栏来进行传值
//$nr=$_GET["sousuolan"];
$Dao=M('list'); $tiaojian['title']=array('like',"%$nr%");$tiaojian['jianjie']=array('like',"%".$_GET["sousuolan"]."%");$where['_logic'] = 'or';// 构造查询条件// 计算总数$count = $Dao->where($tiaojian)->count();// 导入分页类import("ORG.Util.Page");// 实例化分页类$p = new \Think\Page($count, 1);// 获取查询参数$map['jianjie'] = $_GET['sousuolan'];foreach ($tiaojian as $key => $val) { if(is_array($val)){ $Page->parameter .= "$key=" . urlencode ( trim($val[1],'%') ) . "&";}else{ $Page->parameter .= "$key=" . urlencode ( $val ) . "&";}}// 分页显示输出$page = $p->show();// 当前页数据查询$list = $Dao->where($tiaojian)->order('code ASC')->limit($p->firstRow.','.$p->listRows)->select();// 赋值赋值$this->assign('page', $page);$this->assign('list', $list);$this->display();