PHP and MySQL implementation of data paging display instances

Source: Internet
Author: User
This article is mainly to share with you PHP and MySQL implementation data paging display instances, I hope to help everyone.

    1. Get the number of records in the result set you can use the count () function in a SELECT statement to get the number of records in the result set

    2. Set the number of display records per page assume that a variable is used $PageSize to hold the number of displayed records per page, and that its value is set by the user as needed, and can be implemented directly through an assignment statement.

    3. Get the total number of pages can be $RecordCount $PageSize calculated with two data to get the total number of pages $PageCount ,

    4. How to display records on page n although using the PageSize property, you can control the number of records displayed per page, but what are the records displayed? You can use the limit clause in a SELECT statement to specify the scope of the query record, using the following method: SELECT * from table name limit start position, display number of records for example, to get the $Page records on page, you can use the following statement:SELECT * FROM 表名LIMIT ($Page- 1) * $ PageSize, $ PageSize

    5. How to tell the script which page number to display can tell the script to display the page number by passing the parameter. Assume that the script that is marked for paging is viewpage. PHP, the link to pass parameters is as follows: The http:// localhost/ viewPage. php? page= 2 parameter page is used to specify the current page number. In ViewPage. In PHP, use the following statement to read the parameters:

<!doctype html>


    1. Get the number of records in the result set you can use the count () function in a SELECT statement to get the number of records in the result set

    2. Set the number of display records per page assume that a variable is used $PageSize to hold the number of displayed records per page, and that its value is set by the user as needed, and can be implemented directly through an assignment statement.

    3. Get the total number of pages can be $RecordCount $PageSize calculated with two data to get the total number of pages $PageCount ,

    4. How to display records on page n although using the PageSize property, you can control the number of records displayed per page, but what are the records displayed? You can use the limit clause in a SELECT statement to specify the scope of the query record, using the following method: SELECT * from table name limit start position, display number of records for example, to get the $Page records on page, you can use the following statement:SELECT * FROM 表名LIMIT ($Page- 1) * $ PageSize, $ PageSize

    5. How to tell the script which page number to display can tell the script to display the page number by passing the parameter. Assume that the script that is marked for paging is viewpage. PHP, the link to pass parameters is as follows: The http:// localhost/ viewPage. php? page= 2 parameter page is used to specify the current page number. In ViewPage. In PHP, use the following statement to read the parameters:

<!doctype html>

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.