PHP dynamic paging function, PHP development paging essential _ PHP Tutorial

Source: Internet
Author: User
PHP dynamic paging function, which is essential for PHP development paging. Paste code: Copy the code as follows: * ** paging function ** @ paramint $ count total number of entries * @ paramint $ perlogs number of entries displayed per page * @ paramint $ page current page number * @ paramst code:

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;
}

The pipeline code is as follows: /*** paging function ** @ param int $ count total number of entries * @ param int $ perlogs number of entries displayed per page * @ param int $ current page number * @ param st ...

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.