验证数据库
<?php
include("conn.php");
$sql = "select * from shuju";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
$pageSize = 2;
$totalPage = $count % $pageSize == 0 ? (int)($count / $pageSize):(int)($count / $pageSize)+1;
$page = 0;
if(isset($_GET['page'])){
$page = $_GET['page'];
}else{
$page = 1;
}
$pagePos = ($page - 1) * $pageSize;
$sql = "select * from shuju limit $pagePos,$pageSize";
$result = mysql_query($sql);
?>
翻页
共有<?php
echo $count;
?>条数据
共有<?php
echo $totalPage;
?>页
<?php
for($i=1;$i<=$totalPage;$i++){
?>
<a href="booklist.php?page=<?php echo $i; ?>"><?php echo $i; ?></a>
<?php } ?>
<a href="booklist.php?page=<?php if($page >= $totalPage){echo $totalPage;}else{ echo $page+1;} ?>">下一页</a>
跳转到 <input type="text" name="" onkeyup="this.value=this.value.replace(/D/g,'')" id="jumpPage" maxlength="3" size="3"/>页
</body>
<script>
var jp = document.getElementById("jumpPage");
jp.onkeydown = function(e){
var e = e || window.event;
if(e.keyCode == 13){
location.href = "booklist.php?page="+jp.value;
}
}