Home >Database >Mysql Tutorial >基础分页 php+mysql_MySQL

基础分页 php+mysql_MySQL

WBOY
WBOYOriginal
2016-06-01 13:10:16890browse

读取表中的数据,并且分页

//分页算法
$pagesize = 10; //读取10条数据
$pagenum = $GET['page'] ? $GET['page'] : 1; //检索当前在第几页
$offset = ($pagenume - 1) * $pagesize;

$sql = “SELECT * FROM income order by id {$offset},{$pagesize} “;

//获取上下页
$nextpage = $pagenum + 1;
$prevpage = $pagenum - 1;

输出

上一页 | 下一页

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