Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize record pagination by php

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to achieve record paging in php. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Php realizes the idea of record paging: 1, get the number of records in the result set; 2, set the number of records displayed on each page; 3, get the total number of pages; 4, control the number of records displayed on each page; 5, notify the page number displayed by the script by passing parameters.

This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.

What is the idea of php to achieve record paging?

PHP+Mysql implements data paging display:

To get the number of records in the result set, you can use the COUNT () function in the SELECT statement to get the number of records in the result set.

Setting the number of display records per page assumes that the variable $PageSize is used to save the number of display records per page, and its value is set by the user as needed, which can be achieved directly through the assignment statement.

To obtain the total number of pages, you can calculate the total number of pages by using the data of $RecordCount and $PageSize $PageCount

How to display the records on page n although you can use the PageSize property to control the number of records displayed per page, which records do you want to display? You can use the LIMIT clause in the SELECT statement to specify the range of query records as follows: SELECT * FROM table name LIMIT starting position, showing the number of records, for example, to get records on page $Page, you can use the following statement: SELECT * FROM table name LIMIT ($Page- 1) * $PageSize, $PageSize

How to notify the page number to be displayed by the script can be notified of the page number displayed by the script by passing parameters. Suppose the script that shows the record in paging is viewPage. Php, the link for passing parameters is as follows: http:// localhost/ viewPage. Php? The page= 2 parameter page is used to specify the current page number. In viewPage. In php, use the following statement to read the parameters:

Document employee name, position, salary

This is the end of the article on "how to achieve record paging in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development