YOURPHP的查询
html代码
<?php print_r($ser[‘searchtype‘]);?> <select name="searchtype"> <option value="name" <if condition="$ser[‘searchtype‘] ==name">selected="selected"</if>>姓名</option> <option value="mobile" <if condition="$ser[‘searchtype‘] ==mobile">selected="selected"</if>>手机</option> </select> <select name="status" id="status"> <option value="null" <if condition="$ser[‘status‘]===‘null‘">selected="selected"</if>>完成</option> <option value="1" <if condition="$ser[‘status‘] ==‘1‘">selected="selected"</if>>是</option> <option value="0" <if condition="$ser[‘status‘] ==‘0‘">selected="selected"</if>>否</option> </select> <select name="sort"> <option value="asc" <if condition="$ser[‘sort‘] ==asc">selected="selected"</if>>时间递增</option> <option value="desc" <if condition="$ser[‘sort‘] ==desc">selected="selected"</if>>时间递减</option> </select> <select name="listRows"> <option value="15" <if condition="$ser.listRows ==5">selected="selected"</if>>15{:L(‘listRows‘)}</option> <option value="20" <if condition="$ser.listRows ==20">selected="selected"</if>>20{:L(‘listRows‘)}</option> <option value="50" <if condition="$ser.listRows ==50">selected="selected"</if>>50{:L(‘listRows‘)}</option> <option value="100" <if condition="$ser.listRows ==100">selected="selected"</if>>100{:L(‘listRows‘)}</option> </select>
php代码
public function index(){ $m = M(‘service‘); //**** 查询条件 $ser[‘keywords‘] =$_GET[‘keywords‘]; $ser[‘searchtype‘]= $_GET[‘searchtype‘]; $ser[‘status‘] = $_GET[‘status‘]; $ser[‘listRows‘] = $_GET[‘listRows‘]; $ser[‘sort‘] = $_GET[‘sort‘]; $mo = URL(‘Admin-Service/index‘); $url = $mo.‘&keywords=‘.$ser[‘keywords‘].‘&searchtype=‘.$ser[‘searchtype‘].‘&status=‘.$ser[‘status‘].‘&sort=‘.$ser[‘sort‘].‘&listRows=‘.$ser[‘listRows‘].‘&p=‘; $p = $_GET[‘p‘]; //echo $url; //******分页 $res = $m->select(); // 共有几条 $totalNum = count($res); // 共有多少页 $pagesize = ‘3‘; ///$ser[‘listRows‘] $totalpage1 = $totalNum/$pagesize; $totalpage = intval($totalpage1); if($totalpage1 !=0){ $totalpage +=1; } if($totalpage<=0){ $totalpage = 1; } //echo $totalpage; //当前页 $nowpage = $p; if(empty($p)){ $nowpage = 1; } $nowsize = $nowpage*$pagesize-$pagesize;; //echo $nowpage; //第一页 $firstpage = $url.‘1‘; //上一页 $prevpage = $nowpage-1; if($prevpage<=0){ $prevpage = 1; } $prevpageUrl = $url.$prevpage; //下一页 $nextpage = $nowpage+1; if($nextpage>=$totalpage){ $nextpage = $totalpage; } $nextpageUrl = $url.$nextpage; //尾页 $lastpage = $url.$totalpage; //******分页结束 $list = $m->limit($nowsize,$pagesize)->select(); foreach($list as $k=>$v){ $list[$k][‘problem‘] = $this->config_problem(‘1‘,$v[‘problem‘]); } $page = ‘<a class="a1">共‘.$totalNum.‘条 当前‘.$nowpage.‘/‘.$totalpage.‘页</a>‘; $page .= ‘<a href="‘.$firstpage.‘">第一页</a>‘; $page .= ‘<a href="‘.$prevpageUrl.‘">上一页</a>‘; $page .= ‘<a href="‘.$nextpageUrl.‘">下一页</a>‘; $page .= ‘<a href="‘.$lastpage.‘">尾页</a>‘; //$page = ‘30条第一页上一页12下一页最后一页‘; //print_r($ser[‘searchtype‘]); $this->assign(‘ser‘,$ser); $this->assign(‘page‘,$page); $this->assign(‘list‘,$list); $this->display(); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。