Home > Backend Development > PHP Tutorial > php?分页,该怎么处理

php?分页,该怎么处理

WBOY
Release: 2016-06-13 12:25:44
Original
847 people have browsed it

php?分页
从数据库的读出N条数据,想对这N条数据进行分页

1,我如何对这些数据进行分页,使它每页显示10条数据
2.如何计算出一共有多少页

希望能给个例子参考下

------解决思路----------------------
分页可以这样写

<br />$page = 1; // 要现实第几页的数据<br />$pagesize = 10; // 每页显示10条数据<br /><br />$offset = ($page-1)*$pagesize; // 根据页数与每页记录数,计算偏移数<br /><br />$sqlstr = "select * from table limit ".$offset.",".$pagesize;<br />
Copy after login

------解决思路----------------------
不要!
$page 是传入的
$pagesize 是在程序里指定的
$offset 是计算出来的

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template