There are two paging styles for php, mysql, and html: Digital paging and text paging.

Source: Internet
Author: User

Please do not pirated, reproduced please add source http://blog.csdn.net/yanlintao1

Please do not pirated, reproduced please add source http://blog.csdn.net/yanlintao1

First, we hope to present the style and give you comments and suggestions:

First: Digital Paging

Type 2: Text Paging


Php paging function (I wrote it in the common. inc. php public file introduced below ):

/** _ Page () parameters related to paging * @ param int $ _ pagesize several friends exist on each page * @ param $ _ SQL get all fields **/function _ page ($ _ SQL, $ _ size) {global $ _ pagenum, $ _ pagesize, $ _ pageabsolute, $ _ num, $ _ page; // paging module and fault tolerance Processing // page number if (isset ($ _ GET ['page']) {$ _ page =$ _ GET ['page']; if (empty ($ _ page) | $ _ page <0 |! Is_numeric ($ _ page) {$ _ page = 1;} else {$ _ page = intval ($ _ page) ;}} else {$ _ page = 1 ;} // There are several friends on each page $ _ pagesize =$ _ size; // get all data synthesis $ _ num = _ num_rows (_ query ($ _ SQL )); // For ceil, see if the value is greater than or equal to 1 and calculate the number of pages if ($ _ num = 0) {$ _ pageabsolute = 1 ;} else {$ _ pageabsolute = ceil ($ _ num/$ _ pagesize);} if ($ _ page >$ _ pageabsolute) {$ _ page =$ _ pageabsolute ;} // start from the data entry of the database $ _ pagenum = ($ _ page-1) * $ _ pagesize ;} /** _ paging function * @ access public indicates that the function is publicly available * @ param int $ _ if the value is 1, pagination is performed by number, if it is 2 pages in text format * $ _ pageabsolute, total number of pages * $ _ page * $ _ num total number of data records */function _ paging ($ _ type) {global $ _ pageabsolute, $ _ page, $ _ num; if ($ _ type = 1) {echo ''; echo'
 
 
    '; For ($ I = 0; $ I <$ _ pageabsolute; $ I ++) {if ($ _ page = ($ I + 1) {echo'
  • '. ($ I + 1 ).'
  • ';} Else {echo'
  • '. ($ I + 1 ).'
  • ';} Echo'
'; Echo ''';} elseif ($ _ type = 2) {echo ''; echo'
    '; Echo'
  • '. $ _ Page.'/'. $ _ pageabsolute.' page |
  • '; Echo'
  • Total'. $ _ Num .'Data entries |
  • '; If ($ _ page = 1) {echo'
  • Homepage |
  • '; Echo'
  • Next page |
  • '; Echo'
  • Last page |
  • ';} Elseif ($ _ page ==$ _ pageabsolute) {echo'
  • Homepage |
  • '; Echo'
  • Previous Page |
  • '; Echo'
  • Last page |
  • ';} Else {echo'
  • Homepage |
  • '; Echo'
  • Previous Page |
  • '; Echo'
  • Next page |
  • '; Echo'
  • Last page |
  • ';} Echo'
'; Echo '';}}

Html code:

* /// Introduce the public file require '. /der/common. inc. php'; // The paging module. The first parameter gets the total number of items, and the second parameter gets the number of friends on each page. global $ _ pagenum, $ _ pagesize; _ page ("SELECT tg_id FROM tg_guest", 2); // retrieves data FROM the database, arranged 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 ");?>
 Boyou  
 <Script type = "text/javascript" src = "js/blog_message.js"> </script>   
 Boyou Interface
        
 
 
( )
"Alt =" ">
"> Send messages
Add friends
Write message
Send flowers
Please do not pirated, reproduced please add 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.