Home > Backend Development > PHP Tutorial > php simple paging, php paging_PHP tutorial

php simple paging, php paging_PHP tutorial

WBOY
Release: 2016-07-12 09:00:52
Original
1003 people have browsed it

php 简单分页,php分页





无标题文档


$conn=mysql_connect("localhost","root","123");
mysql_select_db("qq",$conn);
mysql_query("set names utf8");
$length=5;
$pagenum=isset($_GET['page'])?$_GET['page']:1;
$totsql="select count(*) from q1";
$totarr=mysql_fetch_row(mysql_query($totsql));
$pagetot=ceil($totarr[0]/$length);
if($pagenum>=$pagetot){
$pagenum=$pagetot;
}
$offset=($pagenum-1)*$length;
$sql="select * from q1 order by id limit {$offset},{$length}";
$ret=mysql_query($sql);
echo "

";
echo "";
while($row=mysql_fetch_assoc($ret)){
echo "";
echo "";
echo "";
echo "";
echo "";
}
echo "
{$row['id']}{$row['name']}{$row['pass']}
";
$prevpage=$pagenum-1;
$nextpage=$pagenum 1;
echo "

|

";
echo "
";
mysql_close($conn);

 

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1091268.htmlTechArticlephp 简单分页,php分页 !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html xmlns="http://www.w3.org/1...
Related labels:
php
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