Php simple paging code example-php Tutorial

Source: Internet
Author: User
Php simple paging code example
Share a simple php paging code that is suitable for beginners of php.

Code:

     
     
    "; // Previous Page if ($ offset> 0) {$ result. ="
  • Prev
  • ";}$ Pages = $ allPageNums; // total page size $ page = $ curPage; // Current page size $ page_len = 9; $ page_len = ($ page_len % 2 )? $ Page_len: $ pagelen + 1; // Number of pages $ pageoffset = ($ page_len-1)/2; // offset between pages if ($ pages> $ page_len) {// if the current page is less than or equal to the left offset if ($ page <= $ pageoffset) {$ init = 1; $ max_p = $ page_len ;} else {// if the current page is greater than the left offset // if the right offset of the current page exceeds the maximum number of pages if ($ page + $ pageoffset >=$ pages + 1) {$ init = $ pages-$ page_len + 1;} calculation of else {// when both the left and right offsets exist $ init = $ page-$ pageoffset; $ max_p = $ page + $ pageoffset ;}}for ($ I = $ init; $ I <= $ max_p; $ I ++) {if ($ I ==$ curPage) {$ result. ="
  • $ I
  • "; Continue;} $ result. ="
  • $ I
  • ";}// Print the next page if ($ allnums> ($ offset + $ maxrow) {$ result. ="
  • Next
  • ";}?>

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.