Two pagination styles for php,mysql,html and text pagination for your reference

Source: Internet
Author: User

Do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1

Do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1

First of all, the style display hope to help you, but also hope that you give comments and suggestions:

First Type: Digital paging

The second type: for the text of this page


PHP Paging Functions (I write in the common.inc.php common file introduced below):

/* *_page () paging parameters * @param int $_pagesize few friends per page * @param $_sql get all fields * */function _page ($_sql,$_size) {Global $_page    Num,$_pagesize,$_pageabsolute,$_num,$_page;        Paging module and fault tolerance processing//page if (isset ($_get[' page ')) {$_page = $_get[' page ']; if (Empty ($_page) | | | $_page<0| |!        Is_numeric ($_page)) {$_page = 1;        }else{$_page = intval ($_page);    }}else{$_page = 1;    }//Each page has several friends $_pagesize = $_size;    Get all data Integrated $_num = _num_rows (_query ($_sql));    Ceil see greater than or equal to 1 for rounding, calculate how many pages if ($_num = = 0) {$_pageabsolute = 1;    }else{$_pageabsolute = ceil ($_num/$_pagesize);    } if ($_page>$_pageabsolute) {$_page=$_pageabsolute; }//Starting with the first data in the database $_pagenum = ($_page-1) *$_pagesize;} /* * _paging Paging function * @access public indicates that the function is publicly available * @param int $_type If 1 is paged by number, if 2 is paginated by text * $_pageabsolute Total number of pages * $_page Page * $    _num altogether how many data * */function _paging ($_type) {global $_pageabsolute,$_page,$_num;    if ($_type==1) {    Echo ' <div id= ' page_num > ';               Echo ' <ul> '; for ($i =0; $i <$_pageabsolute; $i + +) {if ($_page== ($i + 1)) {echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($i + 1). ' " Class= "Selected" > ". ($i + 1). '            </a></li> '; }else{Echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($i + 1). ' " > '. ($i + 1). '            </a></li> ';        }} echo ' </ul> ';    Echo ' </div> ';       }elseif ($_type==2) {echo ' <div id= ' page_text ' > ';       Echo ' <ul> '; Echo ' <li> '. $_page. '       /'. $_pageabsolute. ' Page |</li> ';        Echo ' <li> total <strong> $_num ' </strong> data |</li> ';           if ($_page==1) {echo ' <li> home |</li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($_page+1). ' "    > Next </a> |           </li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. $_pageabsolute. ' " > Last </a>    |       </li> '; }elseif ($_page==$_pageabsolute) {echo ' <li><a href= '. SCRIPT. '.    Php?page=1 "> Home </a> |                                 </li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($_page-1). ' "    > Prev </a> |           </li> ';       Echo ' <li> last |</li> '; }else{Echo ' <li><a href= '. SCRIPT. '.    php > Home </a> |           </li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($_page-1). ' "    > Prev </a> |           </li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. ($_page+1). ' "    > Next </a> |           </li> '; Echo ' <li><a href= '. SCRIPT. '. Php?page= '. $_pageabsolute. ' "    > End </a> |        </li> ';          } echo ' </ul> ';            Echo ' </div> '; }}

HTML code:

*///introduced public file require './includer/common.inc.php ';//paging module, the first parameter gets the total number of bars, the second parameter obtains a few friends global $_pagenum,$_pagesize;_page per page ( "Select tg_id from Tg_guest", 2);//Fetch data from the database, in the order of registration Time $_result = _query ("Select tg_username,tg_sex,tg_face,tg_id from Tg_guest ORDER by Tg_reg_time DESC LIMIT $_pagenum,$_pagesize ");? ><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1

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.