分页是怎么保持查询条件

浏览:2077 发布日期:2014/07/15 分类:求助交流
我有一个列表页显示表里的所有数据,有一个搜索功能,搜索后显示满足条件的结果,点击下一页后,又显示所有结果
点击下一页时,怎么把搜索条件传过去啊,我的搜索是用post传的值$city = I('post.city');
        if(!empty($city)){
            $map['aid_2'] = $city;
        }
        //获取满足要求的总记录数
        $total = D('basicBusinesszone')->where($map)->count();
        foreach($map as $key=>$val){
            $Page->parameter .= "$key=".urlencode($val).'&';
        }
        //设置分页
        $REQUEST = (array)I('request.');
        if( isset($REQUEST['r']) ){
            $listRows = (int)$REQUEST['r'];
        }else{
            $listRows = C('LIST_ROWS') > 0 ? C('LIST_ROWS') : 10;
        }
        $Page = new \Think\Page($total, $listRows);
        $p = $Page->show();
        $this->assign('_page', $p ? $p: '');
        $this->assign('_total', $total);

        //获取数据列表
        $lists = D('basicBusinesszone')->where($map)->limit($Page->firstRow.','.$Page->listRows)->order('sortid asc,id asc')->select();
        $this->assign('_lists', $lists); //列表

        
        cookie('__forward__', $_SERVER['REQUEST_URI']);
        $this->display();
最佳答案
评论( 相关
后面还有条评论,点击查看>>