首先是 借鉴 的代码
//商品列表页面
public function index(){
$name= I('get.name') ? I('get.name') : "";//商品名称
$advertiser_id= I('get.advertiser_id') ? I('get.advertiser_id') : "";//广告主id
$start_time = I('get.start_time') ? I('get.start_time') : "";
$end_times = I('get.end_time') ? I('get.end_time') : "";
$end_time = $end_times." 23:59:59";
$s1 = strtotime($start_time);//开始的时间戳
$e1 = strtotime($end_time);//结束的时间戳
$where = [];
if($name)
{
$where['ap.name'] = array('like',"%$name%");
}
if($advertiser_id)
{
$where['ap.advertiser_id'] = $advertiser_id;
}
if($s1 && $e1 !==''){
$where['ap.add_time'] = array('between',array($s1,$e1));
}
$p_num= 2;
$count = D('ApiProduct')->counts($where);// 查询满足要求的总记录数
$Page = new \Think\Page($count,$p_num);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$page_begin= $Page->firstRow;
//搜索条件
$map['name'] = $name;
$map['start_time'] = $start_time;
$map['end_time'] = $end_times;
$map['advertiser_id'] = $advertiser_id;
$Page->parameter = array_map('urldecode',$map);
$show = $Page->show();// 分页显示输出
$list = D('ApiProduct')->allDatas($where,$page_begin,$p_num);
$wheres=[];
$lists = D('ApiAdvertiser')->allData($wheres);//查询广告主
$this->assign("page", $show);
$this->assign('list',$list);
$this->assign('name',$name);
$this->assign('options', $lists);
$this->assign('start', $start_time);
$this->assign('end', $end_times);
$this->display();
}
主要代码
//后台PHP文件
public function index(){
$name = I('name');
if(!empty($name)){
$where['name'] = array('like','%'.$name.'%');;
$val['name'] = $name;
}
$remark = I('remark');
if(!empty($remark)){
$where['remark'] = array('like','%'.$remark.'%');
$val['remark'] = $remark;
}
$job = I('job');
if(!empty($job) && $job>0){
$where['job'] = $job;
$val['job'] = $job;
}
$table = M('summit');
$count = $table->where($where)->count();
$Page = new \Think\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
//分页跳转的时候保证查询条件
$Page->parameter = array_map('urldecode',$val);
$show = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $table->where($where)->order('register_time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('val',$val);
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出
$this->display();
}
//前台 html
<form class="js-ajax-form" action="" method="post">
<table class="table">
<thead>
<tr>
<th>姓名</th>
<th>手机号</th>
<th>企业全称</th>
<th>职务</th>
<th>参会类别</th>
<th>推荐人</th>
<th>是否参保</th>
<th>身份证号</th>
<th>是否支付</th>
<th>支付时间</th>
<th>是否签到 </th>
<th>签到时间</th>
<th>报名时间</th>
</tr>
</thead>
<foreach name="list" item="v">
<tr>
<td class="center">{$v.name}</td>
<td class="center">{$v.phone}</td>
<td class="center">{$v.company}</td>
<td class="center">{$v.job}</td>
<td class="center">{$v.congress_type}</td>
<td class="center">{$v.remark}</td>
<td class="center">{$v.is_insure}</td>
<td class="center">{$v.idcard}</td>
<if condition="$v['status'] eq '否' ">
<td class="center" style="color:#F00">{$v.status}</td>
<else />
<td class="center">{$v.status}</td>
</if>
<td class="center">{$v.pay_time}</td>
<td class="center">{$v.is_sign}</td>
<td class="center">{$v.sign_time}</td>
<td class="center">{:date('Y-m-d H:i:s',$v['register_time'])}</td>
</tr>
</foreach>
<td colspan="3" bgcolor="#FFFFFF">
<div class="pages">
{$page}
</div>
</td>
</table>
</form>
网友评论