Php classic paging supports 10 Code under 10 pages-PHP source code

Source: Internet
Author: User
Ec (2); php classic paging supports 10 codes & nbsp; + ------------------------------------------------- & nbsp; | & nbsp; Autohr & nbsp ;: & nbsp; jimmy & nbsp; | & nbsp; Email & nbsp;: & nbsp; mailangel123@163.com & nbsp; | & nbs script ec (2); script

Php classic paging supports 10 Code on 10 pages
+ -------------------------------------------
|
| Autohr: jimmy
| Mail: mailangel123@163.com
|
+ -------------------------------------------
*/

/*
+ -------------------------------------------
+ Page unavailable
+ -------------------------------------------
*/
If (@! $ Perpage |! Is_numeric (@ $ perpage) | @ $ perpage <= 0 ){
$ Perpage = 20;
}
/*
+ -------------------------------------------
+ Collect the total data records of the maximum page tds record
+ -------------------------------------------
*/
$ Pages = ceil ($ tds/$ perpage );
/*
+ -------------------------------------------
+ Maximum statistics page
+ -------------------------------------------
*/
$ Page = $ page> $ pages? $ Pages: $ page;
$ Page = is_numeric ($ page) & $ page> 0? Ceil ($ page/1): 1;
/*
+ -------------------------------------------
+ How many records are retrieved?
+ -------------------------------------------
*/
$ Pages_limit = ($ page-1) * $ perpage;
$ Pages_offset = $ perpage;
/*
+ -------------------------------------------
+ Start page and end page
+ -------------------------------------------
*/
If ($ pages <= 10 ){
$ Spage = 1;
$ Epage = $ pages;
} Else {
If ($ page> $ pages-5 ){
$ Spage = $ pages-9;
$ Epage = $ pages;
} Elseif ($ page <6 ){
$ Spage = 1;
$ Epage = 10;
} Else {
$ Spage = $ page-4;
$ Epage = $ page + 5;
}
}
/*
+ -------------------------------------------
+ Previous and next pages
+ -------------------------------------------
*/
$ Pages_prev = $ page <= 2? 1: ($ page-1 );
$ Pages_next = $ page >=$ pages-1? $ Pages: ($ page + 1 );

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.