标签:
$pagnow当前页
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>webrx-php</title>
</head>
<body>
<?php
include ‘inc/db_mysqli.php‘;
$rr = $m->query(‘select count(*) from member‘);
$rs = $rr->fetch_row();
$recordcount = $rs[0]; //共13条记录
$pagesize = 1; //每页两条记录
$pagecount = ceil($recordcount/$pagesize); //总页数
$currpage = isset($_GET[‘p‘]) ? $_GET[‘p‘] : 1;//当前页
$currpage = $currpage<=1 ? 1 : $currpage;
$currpage = $currpage>=$pagecount ? $pagecount : $currpage;
$start = $currpage*$pagesize-$pagesize;
$r = $m->query("select id,maccount,mname from member limit $start,$pagesize");
while($rs = $r->fetch_row()){
echo $rs[1].‘<br>‘;
}
echo ‘<hr>‘;
for($j=1;$j<=$pagecount;$j++){
if($currpage == $j){
echo $j.‘ ‘;
continue;
}
echo "<a href=‘?p=$j‘>$j</a> ";
}
?>
<hr>
<a href="?p=1">首页</a>
<a href="?p=<?=$currpage+1?>">下页</a>
<a href="?p=<?php echo $currpage-1;?>">上页</a>
<a href="?p=<?=$pagecount?>">末页</a>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/lsr111/p/4532181.html