Home  >  Article  >  Backend Development  >  How to implement paging interface in php

How to implement paging interface in php

藏色散人
藏色散人Original
2021-11-19 09:00:322435browse

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.

How to implement paging interface in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn