搜索分页

 */ 
public function __construct($totalRows, $listRows=20, $parameter = array()) {
C('VAR_PAGE') && $this->p = C('VAR_PAGE'); //设置分页参数名称
/* 基础设置 */
$this->totalRows = $totalRows; //设置总记录数
$this->listRows = $listRows; //设置每页显示行数
$this->parameter = empty($parameter) ? $_GET : $parameter;
$this->nowPage = empty($_GET[$this->p]) ? 1 : intval($_GET[$this->p]);
$this->nowPage = $this->nowPage>0 ? $this->nowPage : 1;
$this->firstRow = $this->listRows * ($this->nowPage - 1);
}


控制器
$count = $model->where($where)->order('id desc')->count();
$Page       = new ThinkPagenew($count,10);
$show = $Page->show();
$maxtype=M('classification')->where('pid=0')->select();

$data_info = D('Product')->where($where)->order('id desc')->limit($Page->firstRow,$Page->listRows)->select();

$this->assign('maxtype',$maxtype);
$this->assign('data',$data_info);
$this->assign('page',$show);



<div class="text-center">
<ul class="pagination">
{$page}
</ul>
</div>


<form id="search_form" action="<?php echo U('Admin/Product/index');?>"  role="form" class="form-inline" method="get" style="float: right;margin-left: 100px;font-size: 16px">
<div class="form-group">
<label class="">大分类:</label>
<select name="max" class="form-control" style=" 200px" id="max" >
<option value="" >--请选择大分类--</option>
<volist name="maxtype" id='vvo' >
<option value="<?php echo $vvo['id'];?>" <?php if($max==$vvo['id']){ echo selected;} ?> ><?php echo $vvo['name'];?></option>
</volist>
</select>

<label class="">小分类:</label>
<select name="two" class="form-control" style=" 200px" id="two">
<option value="" >--请选择小分类--</option>
<?php if(!empty($s_class)){ foreach($s_class as $k=>$v){?>
<option value="<?php echo $v['id'];?>" <?php if($two==$v['id']){ echo selected;} ?> ><?php echo $v['name'];?></option>
<?php } } ?>

</select>

<label class="">品牌:</label>
<select name="brand_id" class="form-control" style=" 200px" id="pinpai">
<option value="" >--请选择品牌--</option>
<?php if(!empty($brand_data)){ foreach($brand_data as $k=>$v){?>
<option value="<?php echo $v['brand_id'];?>" <?php if($brand_id === $v['brand_id']){ echo selected;} ?>><?php echo $v['brand_name']; ?></option>
<?php } } ?>
</select>

</div>


原文地址:https://www.cnblogs.com/maohongli/p/12875084.html