Php paging-php Tutorial

Source: Internet
Author: User
Php pagination & lt ;? Php $ pageCount9; total page number $ pageNow3; user-input page number $ i3; displayed page number $ j $ pageCount $ I; number of times that can be rolled $ arrarray (); control the number of scrolling times for ($ k0; $ k & lt; $ j; $ k ++) {control paging if ($ pa php paging


$ PageCount = 9; // total number of pages
$ PageNow = 3; // Number of pages entered by the user
$ I = 3; // number of displayed pages
$ J = $ pageCount/$ I; // The number of times that you can scroll
$ Arr = array ();

// Control the number of scrolling times
For ($ k = 0; $ k <$ j; $ k ++ ){

// Control paging
If ($ pageNow = 3 * $ k ){

For ($ e = ($ k * 3) + 1; $ e <= 3 * ($ k + 1); $ e ++ ){

$ Arr [] = $ e;
// Echo $ e;
}
// Echo"
";
} Else {
// Output the current page number
For ($ a = 0; $ a <$ I; $ a ++ ){
$ Arr [$ a];

}

}
}

?>
Let's take a look at the problem.





------ Solution --------------------
PHP code
$ PageCount = 9; // total page number $ pageNum = 3; // number of displayed pages $ pageNow = $ _ GET ['Page']? $ _ GET ['Page']: 1; // Number of pages entered by the user if ($ pageNow = $ pageCount) $ pageNow = 1; // scroll cyclically, add this sentence $ pageStart = floor ($ pageNow/$ pageNum) * $ pageNum + 1; // display the starting page number $ pageEnd = $ pageStart + $ pageNum; // display the ending page number + 1for ($ I = $ pageStart; $ I <$ pageEnd; $ I ++) {echo "[$ I]";}

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.