Php paging principle discussion, php paging code example

Source: Internet
Author: User
Php paging principle discussion, php paging code example

  1. Select * from book limit 0, 5;
  2. Select * from book limit 5, 5;
  3. Select * from book limit 10, 5;

The first statement is to search for five pieces of information from scratch, and the second statement is to search for five pieces of information from 5. The third statement is unnecessary.

First, 0 = (1-1) * 5, 5 = (2-1) * 5, 10 = (3-1) * 5. here we need to understand 1, 2, 3 represents what, and 5 represents what. 1, 2, 3 indicates the current page, that is, the first, second, and third pages; 5 indicates the number of records displayed.

Obtain the query formula:

  1. Select * from book limit ($ pageval-1) * $ pagesize, $ pagesize;

How to obtain the $ page value. Here, we use $ _ GET (page) to obtain it.

Specific steps: First, determine the number of output records $ pagesize = 5; use $ url = $ _ srever ["request_uri"]; to obtain the current url, and then use parse_url () parse the url and obtain the path value. This is the url in the page.

Php paging code:

[Code]

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.