[Original] paging Elementary tutorial, suitable for beginners. how can this problem be solved?

Source: Internet
Author: User
[Original] the paging Elementary tutorial is suitable for beginners who call for the neighborhood moderator. You can watch it for new users. PHPcode & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot; http: // [original] paging Elementary tutorial, suitable for beginners
The call of the corresponding Niu moderator is ugly, and the right should be a reference. You can watch it for new users.


PHP code
  
  Paging instance
  $ Total_page? $ Total_page: $ page; // avoid $ _ GET ["page"] exceeding the total number of pages // The page turning link starts $ page_link = ""; if ($ total_page> 1) {$ page_link = "total {$ total_page} pages"; $ page_link. = "current page {$ page}"; $ page_link. = "homepage"; if ($ page> 1) {// when the page number is greater than 1, the page turning link of the previous page is displayed $ pre_page = $ page-1; $ page_link. = "<" ;}// page flip list for ($ I = 1; $ I <= $ total_page; $ I ++) {if ($ I = $ page) {// highlight the current page number $ page_link. = "$ I";} else {$ page_link. = "$ I" ;}}// when the page number is smaller than the total page number, the next page flip link is displayed. $ next_page = $ page + 1; if ($ next_page <$ total_page) {$ page_link. = ">" ;}$ page_link. = "Last page";} // output record $ offset = ($ page-1) * $ page_size; $ query = mysql_query ("select * from product limit $ offset, $ page_size ") or die (mysql_error (); echo"
  
  
    "; While ($ rs = mysql_fetch_array ($ query) {echo"
  • {$ Rs ["id"]}-{$ rs ["ename"]}
  • ";} Echo"
      "; Echo" $ page_link ";?>


Think about the following questions:

1. if there are many page numbers, there may be hundreds. how can I output this link list?



Not yet to be continued ....

------ Solution --------------------
Thank you for sharing. my pages are all on the homepage. the last page of the previous page has a total of X pages. there is a list of intermediate pages. thank you, Jordan!
------ Solution --------------------
Thank you! I'm a newbie ......
------ Solution --------------------
I wrote a general paging code for JAVA. Similar to the following:

<[1] [2] [3] 4 [5] [6] [7] [8] [9] [10]>
Click>
<11 [12] [13] [14] [15] [16] [17] [18] [19] [20]>
Click> Later
<21 [22] [23]

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.