> 백엔드 개발 > PHP 튜토리얼 > phpZF框架下类似Google搜索分页_PHP教程

phpZF框架下类似Google搜索分页_PHP教程

WBOY
풀어 주다: 2016-07-13 10:38:47
원래의
1113명이 탐색했습니다.

[代码] [PHP]代码

view source print? 01 /** 02      * 03      * @param unknown_type $model 表类型 04      * @param unknown_type $ncontroller 那个控制器提交的controller 05      * @param unknown_type $naction 那个action提交的action 06      */ 07     public function fenyepage2($model,$ncontroller,$naction){ 08         if(!isset($_SESSION)) 09         {session_start();} 10         $pageSize $_SESSION['pagesize']; 11         $pageNow $_SESSION['pagenow']; 12         $offset $pageNow-1)*$pageSize; 13         $db $this->getAdapter(); 14         $select $db->select(); 15         $select->from('student','*'); 16         if(!isset($_SESSION)) 17         {session_start();} 18         if($_SESSION['qsname']!=""){ 19             $sname $_SESSION['qsname']; 20             $select->where('sname like ?',"%$sname%"); 21         } 22         if($_SESSION['qsaddress']!=""){ 23             $saddress $_SESSION['qsaddress']; 24             $select->where('saddress like ?',"%$saddress%"); 25         } 26         if($_SESSION['qsdept']!=""){ 27             $sdept $_SESSION['qsdept']; 28             $select->where('sdept like ?',"%$sdept%"); 29         } 30         $coutNews $db->fetchAll($select); 31         <code class="variable">$pageCount ceil(count($coutNews)/$pageSize); 32         $select->limit($pageSize,$offset);//第一个参数:总共显示多少个。第二个参数:从第几个开始显示 33         $res $db->fetchAll($select); 34         $native  35         $native "<a href="'%5C%5C%24ncontroller%5C%5C%24naction?pageNow=1&pagesize=%24pageSize'">首页</a>&nbsp"; 36         if($pageNow>1){ 37             $nextPage $pageNow-1; 38             $native.=" <a href="'%5C%5C%24ncontroller%5C%5C%24naction?pageNow=%24nextPage&pagesize=%24pageSize'">上一页</a> "; 39         } 40             if(($pageNow-1)>5){ 41                 if($pageNow+4><code class="variable">$pageCount){//如果最后的页数和理应前面开始的页数小于10则 42                     $start <code class="variable">$pageCount-9;//开始的页数和结束的页数相差9 43                 }else{ 44                     $start$pageNow-5;//开始位置和结束位置相差5 45                 } 46             }else{ 47                 $start floor(($pageNow-1)/10)*10+1; 48             } 49             if(<code class="variable">$pageCount>=$start+10){ 50                 <code class="variable">$index $start+10; 51             } 52             else{ 53                 <code class="variable">$index <code class="variable">$pageCount+1; 54             } 55   56             for(;$start<code class="variable">$index;$start++){ 57                 $native.="  <a href="'%5C%5C%24ncontroller%5C%5C%24naction?pageNow=%24start&pagesize=%24pageSize'">$start</a>"; 58             } 59         if($pageNow<code class="variable">$pageCount){ 60             $nextPage $pageNow+1; 61             $native.="  <a href="'%5C%5C%24ncontroller%5C%5C%24naction?pageNow=%24nextPage&pagesize=%24pageSize'">下一页</a> ";   62         } 63   64         $native.="  <a href="'%5C%5C%24ncontroller%5C%5C%24naction?pageNow=%24pageCount&pagesize=%24pageSize'">末页</a> "; 65         $native.="  当前{$pageNow}||总共{$pageCount}页"; 66         $model->arrs = $res; 67         $model->native = $native; 68     }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/735075.htmlTechArticle[代码] [PHP]代码 view source print? 01 /** 02 * 03 * @param unknown_type $model 表类型 04 * @param unknown_type $ncontroller 那个控制器提交的controller 05 * @param u...
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿