The phpZF framework is similar to Google search paging-PHP source code

Source: Internet
Author: User
In the phpZF framework, Google search pages are similar. In the phpZF framework, Google search pages are similar.

/***** @ Param unknown_type $ model table type * @ param unknown_type $ controller submitted by the ncontroller controller * @ param unknown_type $ action submitted by the naction action */public function fenyepage2 ($ model, $ ncontroller, $ naction) {if (! Isset ($ _ SESSION) {session_start () ;}$ pageSize = $ _ SESSION ['pagesize']; $ pageNow = $ _ SESSION ['pagenow']; $ offset = ($ pageNow-1) * $ pageSize; $ db = $ this-> getAdapter (); $ select = $ db-> select (); $ select-> from ('student ',' * '); if (! Isset ($ _ SESSION) {session_start ();} if ($ _ SESSION ['qsname']! = "") {$ Sname = $ _ SESSION ['qsname']; $ select-> where ('sname like? ', "% $ Sname %");} if ($ _ SESSION ['qsaddress']! = "") {$ Saddress = $ _ SESSION ['qsaddress']; $ select-> where ('saddress like? ', "% $ Saddress %");} if ($ _ SESSION ['qsdept']! = "") {$ Sdept = $ _ SESSION ['qsdept']; $ select-> where ('sdept like? ', "% $ Sdept %") ;}$ coutNews = $ db-> fetchAll ($ select); $ pageCount = ceil (count ($ coutNews)/$ pageSize ); $ select-> limit ($ pageSize, $ offset); // The first parameter: total number of items displayed. The second parameter: $ res = $ db-> fetchAll ($ select); $ native = null; $ native = "homepage "; if ($ pageNow> 1) {$ nextPage = $ pageNow-1; $ native. = "previous page";} if ($ pageNow-1)> 5) {if ($ pageNow + 4> $ pageCount) {// $ start = $ pageCount-9 if the last page number and the number of pages that should have started earlier than 10; // the difference between the start page and the end page 9} else {$ start = $ pageNow-5; // difference between the start position and end position 5} else {$ start = floor ($ pageNow-1)/10) * 10 + 1 ;} if ($ pageCount >=$ start + 10) {$ index = $ start + 10;} else {$ index = $ pageCount + 1 ;}for (; $ start <$ index; $ start ++) {$ native. = "$ start";} if ($ pageNowarrs = $ res; $ model-> native = $ native ;}

The above is the content similar to Google search pages in the phpZF framework. For more information, see PHP Chinese website (www.php1.cn )!

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.