A discussion of PHP paging principle, a case of PHP page code

Source: Internet
Author: User
    1. SELECT * FROM book limit 0, 5;
    2. SELECT * FROM book limit 5, 5;
    3. SELECT * FROM book limit 10, 5;
Copy Code

The first sentence is to find 5 information from the zero, the second is to start from 5 to find 5 information, the third does not have to say more.

First 0 = (1-1), 5 = (2-1), 10 = (3-1) It is here to understand what is represented by the one-to-one, and 5 for what it can be. The current page, that is, the first, second, third page, and 5 is the number of records displayed.

To derive the query formula:

    1. SELECT * FROM book limit ($pageval-1) * $pagesize, $pagesize;
Copy Code

How to get the $page value. This is achieved using $_get (page).

Specific steps: First, determine the number of output records $pagesize=5, the use of $url=$_srever["Request_uri"], to get the current URL, and then through the Parse_url () to resolve the URL, and finally the value of the path is taken out. This is the URL you want in the paging.

PHP Paging Code:

  • Related Article

    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.