thinkphp3.2做前台查询分页怎么做 20
publicfunctionsearch($p=1){$word=I('post.keywords');$map['title']=array('like','%'.$w...
public function search($p=1){
$word = I('post.keywords');
$map['title']=array('like', '%'.$word.'%');
$con['title']=I('post.keywords');
$p = intval($p);
$p = empty($p) ? 1 : $p;
$Document=M('document');
$count = $Document->where($map)->count();
$Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(10)
foreach($con as $key=>$val) {
$Page->parameter[$key] = urlencode($val);
}
// var_dump($Page->parameter);
$show = $Page->show();
$lists=$Document->where($map)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('lists',$lists);
$this->assign('page',$show);
$this->assign('count',$count);
$this->assign('word',$word);
$this->display();
}
第一页显示正常,点击下一页,查询条件丢失 展开
$word = I('post.keywords');
$map['title']=array('like', '%'.$word.'%');
$con['title']=I('post.keywords');
$p = intval($p);
$p = empty($p) ? 1 : $p;
$Document=M('document');
$count = $Document->where($map)->count();
$Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(10)
foreach($con as $key=>$val) {
$Page->parameter[$key] = urlencode($val);
}
// var_dump($Page->parameter);
$show = $Page->show();
$lists=$Document->where($map)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('lists',$lists);
$this->assign('page',$show);
$this->assign('count',$count);
$this->assign('word',$word);
$this->display();
}
第一页显示正常,点击下一页,查询条件丢失 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏20(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询