Php development requires paging code _ PHP Tutorial

Source: Internet
Author: User
Php development requires paging code. During development, this paging function is indispensable. today we will share a very practical and simple php paging function implementation code. if you need it, please refer to it. Code, for example, in development, this paging function must be indispensable. today we will share a very practical and simple php paging function implementation code. if you need it, please refer to it.
The code is as follows:

/**
* Paging functions
*
* @ Param int $ count total number of entries
* @ Param int $ perlogs number of entries displayed per page
* @ Param int $ page current page number
* @ Param string $ url address of the page number
*/
Function pagination ($ count, $ perlogs, $ page, $ url, $ anchor = ''){
$ Pnums = @ ceil ($ count/$ perlogs );
$ Re = '';
$ UrlHome = preg_replace ("| [? &/] [^ ./? & =] * Page [=/-] | "," ", $ url );
For ($ I = $ page-5; $ I <= $ page + 5 & $ I <= $ pnums; $ I ++ ){
If ($ I> 0 ){
If ($ I = $ page ){
$ Re. = "$ I ";
} Elseif ($ I = 1 ){
$ Re. = "$ I ";
} Else {
$ Re. = "$ I ";
}
}
}
If ($ page> 6) $ re = "«...$ Re ";
If ($ page + 5 <$ pnums) $ re. ="...»";
If ($ pnums <= 1) $ re = '';
Return $ re;
}

Bytes. Code such...

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.