Php code for digital paging

Source: Internet
Author: User

Function getnavhtml ($ pagenum, $ pagesize, $ rowcount, $ navurl ){
$ Pagecount = (int) ($ rowcount/$ pagesize); // total number of pages
If ($ rowcount % $ pagesize> 0 ){
$ Pagecount ++;
}
If ($ pagenum> $ pagecount ){
$ Pagenum = 1;
}
$ Firstnav = "<a href =" {$ navurl} page = 1 "> homepage </a> ";
$ Lastnav = "<a href =" {$ navurl} page = {$ pagecount} "> Last page </a> ";
$ Prevnav = "";
$ Nextnav = "";
If ($ pagenum> 1 ){
$ Navpagenum = $ pagenum-1;
$ Prevnav = "<a href =" {$ navurl} page = {$ navpagenum} "> Previous page </a> ";
}
If ($ pagenum <$ pagecount & $ pagecount> 1 ){
$ Navpagenum = $ pagenum + 1;
$ Nextnav = "<a href =" {$ navurl} page = {$ navpagenum} "> Next page </a> ";
}
$ Amongnav = "";

// Key Loop

For ($ I = 1; $ I <= 5; $ I ++ ){
$ Navpagenum = $ pagenum + $ I-3;
If ($ navpagenum> 0 & $ navpagenum <= $ pagecount ){
$ Navcss tutorial = $ navpagenum = $ pagenum? "Class =" hover "":"";
$ Amongnav. = "<a href =" {$ navurl} page ={$ navpagenum} "$ navcss >{$ navpagenum} </a> ";
}
}
Return $ firstnav. $ prevnav. $ amongnav. $ nextnav. $ lastnav. "". $ pagenum. "/". $ pagecount. "Total [". $ rowcount. "] data entries ";
}
}

/**
* Retrieve page number navigation html
* @ Param $ pagenum: current page number
* @ Param $ pagesize: page size
* @ Param $ rowcount: total number of records
* @ Param $ navurl: url of the link page
*/

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.