Home >Backend Development >PHP Problem >How to implement paging interface in php
php method to implement paging interface: 1. Receive page value; 2. Calculate total number of items; 3. Calculate offset; 4. Through "select * from table name limit ($offset,$page) " statement queries the data on each page.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php implement the paging interface?
It’s very simple, everyone must have a good idea.
php Steps to write paging interface:
1. Receive value (current page number $page, number of items displayed on each page $psize)
2. Calculate the total Number of items
3. Calculate the offset
$offset = (当前页数-1)*每页显示条数 $offset = ($page - 1)* $psize
4. Query the data of each page
$data = select * from 表名 limit ($offset ,$page)
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to implement paging interface in php. For more information, please follow other related articles on the PHP Chinese website!