Php custom page class complete instance, _ PHP Tutorial

Source: Internet
Author: User
Complete php custom paging class instance ,. A complete example of php custom paging class. This article describes the php custom paging class. Share with you for your reference, specific: phpheader (Content-type: texthtml; Charsetutf-8) php custom paging class complete instance,

This example describes the php custom paging class. We will share this with you for your reference. The details are as follows:

<? Phpheader ("Content-type: text/html; Charset = utf-8"); class SubPages {private $ each_disNums; // Number of Entries displayed on each page private $ nums; // The total number of items is private $ current_page; // the currently selected page is private $ sub_pages; // The number of pages displayed each time is private $ pageNums; // total number of pages private $ page_array = array (); // array used to construct the pagination private $ subPage_link; // The link to each page/private $ subPage_type; // display page type/* when @ subPage_type = 1, the normal page mode is example: 4523 records in total, 10 records per page, current page 1/453 [Homepage] [Previous Page] [Next Page] [last Page] when @ s When ubPage_type = 2, the classic paging style is example: current page 1/453 [Homepage] [Previous Page] 1 2 3 4 5 6 7 8 9 10 [Next Page] [last Page] */function _ construct ($ each_disNums, $ nums, $ current_page, $ sub_pages, $ subPage_link) {$ this-> each_disNums = intval ($ each_disNums); $ this-> nums = intval ($ nums); if (! $ Current_page) {$ this-> current_page = 1;} else {$ this-> current_page = intval ($ current_page);} $ this-> sub_pages = intval ($ sub_pages ); $ this-> pageNums = ceil ($ nums/$ each_disNums); $ this-> subPage_link = $ subPage_link; // $ this-> show_SubPages ($ subPage_type );} // The show_SubPages function is used in the constructor. And used to determine what the page looks like/* function show_SubPages ($ subPage_type) {if ($ subPage_type = 1) {$ this-> subPageCss1 ();} else if ($ subPage_type = 2) {$ this-> subPageCss2 () ;}} * // the function used to initialize the array for pagination. Function initArray () {for ($ I = 0; $ I <$ this-> sub_pages; $ I ++) {$ this-> page_array [$ I] = $ I;} return $ this-> page_array;}/* construct_num_Page this function is used to construct display entries even if: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] */function construct_num_Page () {if ($ this-> pageNums <$ this-> sub_pages) {$ current_array = array (); for ($ I = 0; $ I <$ this-> pageNums; $ I ++) {$ current_array [$ I] = $ I + 1 ;}} else {$ current_array = $ this-> initArray (); if ($ this-> current_page <= 3) {for ($ I = 0; $ I
 
  
Current_page <= $ this-> pageNums & $ this-> current_page> $ this-> pageNums-$ this-> sub_pages + 1) {for ($ I = 0; $ I
  
   
PageNums)-($ this-> sub_pages) + 1 + $ I ;}} else {for ($ I = 0; $ I
   
    
Current_page-2 + $ I ;}}return $ current_array;}/* construct a total of 4523 records for normal mode pagination, 10 records per page, current page 1/453 [Homepage] [Previous Page] [Next Page] [last Page] */function subPageCss1 () {$ subPageCss1Str = ""; $ subPageCss1Str. = "total ". $ this-> nums. "record,"; $ subPageCss1Str. = "display on each page ". $ this-> each_disNums. ","; $ subPageCss1Str. = "current number ". $ this-> current_page. "/". $ this-> pageNums. "page"; if ($ this-> current_page> 1) {$ firstPageUrl = $ this-> subPage_link. "1"; $ prewPageUrl = $ this-> subPage_link. ($ this-> current_page-1); $ subPageCss1Str. = "[Homepage]"; $ subPageCss1Str. = "[previous page]";} else {$ subPageCss1Str. = "[Homepage]"; $ subPageCss1Str. = "[previous page]";} if ($ this-> current_page <$ this-> pageNums) {$ lastPageUrl = $ this-> subPage_link. $ this-> pageNums; $ nextPageUrl = $ this-> subPage_link. ($ this-> current_page + 1); $ subPageCss1Str. = "[Next Page]"; $ subPageCss1Str. = "[last page]";} else {$ subPageCss1Str. = "[Next Page]"; $ subPageCss1Str. = "[last page]";} return $ subPageCss1Str; // you can set the displayed CSS style here}/* construct the page of the classic mode. Current page 1/453 [Homepage] [Previous Page] 1 2 3 4 5 6 7 8 9 10 [next page] [Last Page] */function subPageCss2 () {$ subPageCss2Str = ""; $ subPageCss2Str. = "current number ". $ this-> current_page. "/". $ this-> pageNums. "page"; if ($ this-> current_page> 1) {$ firstPageUrl = $ this-> subPage_link. "1"; $ prewPageUrl = $ this-> subPage_link. ($ this-> current_page-1); $ subPageCss2Str. = "[Homepage]"; $ subPageCss2Str. = "[previous page]";} else {$ subPageCss2Str. = "[Homepage]"; $ subPageCss2Str. = "[previous page]" ;}$ a = $ this-> construct_num_Page (); for ($ I = 0; $ I
    
     
Current_page) {$ subPageCss2Str. = "[". $ s. "]";} else {$ url = $ this-> subPage_link. $ s; $ subPageCss2Str. = "[". $ s. "]" ;}} if ($ this-> current_page <$ this-> pageNums) {$ lastPageUrl = $ this-> subPage_link. $ this-> pageNums; $ nextPageUrl = $ this-> subPage_link. ($ this-> current_page + 1); $ subPageCss2Str. = "[Next Page]"; $ subPageCss2Str. = "[last page]";} else {$ subPageCss2Str. = "[Next Page]"; $ subPageCss2Str. = "[last page]";} return $ subPageCss2 Str ;}/// use the following/* include ('.. /mysql. php '); // The number of entries displayed per page $ page_size = 3; // The total number of entries $ SQL = mysql_query ("select * from 'Stu _ info '"); $ nums = mysql_num_rows ($ SQL); // The number of pages displayed each time $ sub_pages = 10; // Obtain the current page if (! Isset ($ _ GET ["p"]) {$ pageCurrent = 1 ;}else {$ pageCurrent =$ _ GET ["p"];} $ subPages = new SubPages ($ page_size, $ nums, $ pageCurrent, $ sub_pages, "page. php? P = "); $ page = $ subPages-> subPageCss2 (); echo $ page; // Set the CSS style $ ss = mysql_query ("select * from 'Stu _ info' limit ". $ page_size * ($ pageCurrent-1 ). ",". $ page_size); while ($ row = mysql_fetch_array ($ ss) {echo $ row ['stunum']. ''. $ row ['stamp']. ''. $ row ['clanum'].'
     
';} */?>

I hope this article will help you with PHP programming.

Articles you may be interested in:
  • Two omnipotent php paging classes
  • Php simple paging implementation method
  • PHP pagination collection
  • Thinkphp paging class instance that is similar to dedecms drop-down paging style modification
  • Efficient mongodb php paging class (skip is not used)
  • ThinkPHP usage tips-usage of pagination pages
  • ThinkPHP paging usage
  • Exquisite and beautiful php paging code
  • PHP paging code (simple and easy to use)
  • PHP ajax paging code

Example: php custom paging class. For your reference, see phpheader ("Content-type: text/html; Charset = utf-8 ")...

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.