Php Development _ pagination

Source: Internet
Author: User
Php Development _ pagination project structure:

Running effect:

==========================================================

Conn. php

1
 ", Str_replace (" "," ", $ content); 8 return $ content; 9} 10?>

Page. php

1
 ". ($ Totle? ($ Firstcount + 1): 0 )."-". Min ($ firstcount + $ displaypg, $ totle )."A total of $ totle records "; 36 37 // if there is only one page, the function will jump out: 38 if ($ lastpg <= 1) 39 return false; 40 41 $ pagenav. = "homepage"; 42 if ($ prepg) 43 $ pagenav. = "previous page"; 44 else45 $ pagenav. = "previous page"; 46 if ($ nextpg) 47 $ pagenav. = "back page"; 48 else49 $ pagenav. = "back page"; 50 $ pagenav. = "Last page"; 51 52 // the drop-down Jump List. all pages are displayed cyclically: 53 $ pagenav. = "to\ N "; 54 for ($ I = 1; $ I <= $ lastpg; $ I ++) {55 if ($ I = $ page) 56 $ pagenav. ="$ I\ N "; 57 else58 $ pagenav. ="$ I\ N "; 59} 60 $ pagenav. ="Page, total $ lastpg page "; 61} 62 63 64 include (" conn. php "); 65 66 $ result = mysql_query (" SELECT * FROM 'test "'); 67 $ total = mysql_num_rows ($ result); 68 // call pageft (), 10 messages are displayed on each page (this parameter can be omitted when the default value is 20). the URL on this page is used (default value, so this parameter is omitted ). 69 _ PAGEFT ($ total, 5); 70 echo $ pagenav; 71 72 $ result = mysql_query ("SELECT * FROM 'test' limit $ firstcount, $ displaypg "); 73 while ($ row = mysql_fetch_array ($ result) {74 75 echo"". $ Row [name]." | ". $ row [sex]; 76 77} 78?>

List. php

1
  $ Pagesize) {19 if ($ pageval <= 1) $ pageval = 1; 20 echo "$ num total ". 21 "previous page"; 22} 23 $ SQL = "SELECT * FROM 'test' limit $ page $ pagesize"; 24 $ query = mysql_query ($ SQL ); 25 while ($ row = mysql_fetch_array ($ query) {26 27 echo"". $ Row [name]." | ". $ row [sex]; 28 29} 30?>

Paging formula: (current page-1) * number of entries per page, number of entries per page

SQL statement: select * from test_table limit ($ page-1) * $ pageSize, $ pageSize;

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.