Phpzf similar to Google search page _php tutorial

Source: Internet
Author: User

[Code] [PHP] Code

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 $pageCount = ceil ( count ( $coutNews )/ $pageSize ); 32 $select ->limit( $pageSize , $offset ); //第一个参数:总共显示多少个。第二个参数:从第几个开始显示 33 $res = $db ->fetchAll( $select ); 34 $native = null; 35 $native = "首页 " ; 36 if ( $pageNow >1){ 37 $nextPage = $pageNow -1; 38 $native .= " 上一页 " ; 39 } 40 if (( $pageNow -1)>5){ 41 if ( $pageNow +4> $pageCount ){ //如果最后的页数和理应前面开始的页数小于10则 42 $start = $pageCount -9; //开始的页数和结束的页数相差9 43 } else { 44 $start = $pageNow -5; //开始位置和结束位置相差5 45 } 46 } else { 47 $start = floor (( $pageNow -1)/10)*10+1; 48 } 49 if ( $pageCount >= $start +10){ 50 $index = $start +10; 51 } 52 else { 53 $index = $pageCount +1; 54 } 55 56 for (; $start < $index ; $start ++){ 57 $native .= " $start" ; 58 } 59 if ( $pageNow < $pageCount ){ 60 $nextPage = $pageNow +1; 61 $native .= " 下一页 " ; 62 } 63 64 $native .= " 末页 " ; 65 $native .= " 当前{$pageNow}||总共{$pageCount}页" ; 66 $model ->arrs = $res ; 67 $model ->native = $native ; 68 }

http://www.bkjia.com/PHPjc/735075.html www.bkjia.com true http://www.bkjia.com/PHPjc/735075.html techarticle [code] [PHP] Code view source print?/** * @param unknown_type $model Table type * @param unknown_type $ncontroller The controller submitted by the controllers is * @param u ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.