<body style="font-size:12px;">
<?php
include "conn.php";
$pagesize=10;
$page=$_REQUEST["page"];
if($page==""){
$page=1;
}
else{
$page=$_REQUEST["page"];
}
$totalnum=mysql_result(mysql_query("select count(*) from Message1"),0);
$pagecount=ceil($totalnum/$pagesize);
if($page>$pagecount){
$page=$pagecount;
}
if(!is_numeric($page)){
$page=1;
}
$sql="select content from Message1 limit ".($page-1)*$pagesize.",".$pagesize;
//echo $sql;
$i=0;
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$i=$i+1;
echo (($page-1)*$pagesize+$i).$row["huifu_content"]."<br/>";
}
switch($page)
{
case 1;
echo "第一页|上一页 |<a href=?page=2>下一页</a> | <a href=?page=".$pagecount.">最后一页</a>";
break;
case $pagecount;
echo "<a href=?page=1>第一页</a> |<a href=?page=".($pagecount-1).">上一页</a>|";
echo "下一页 |最后一页";
break;
default;
echo "<a href=?page=1>第一页</a> |<a href=?page=".($page-1).">上一页</a>|";
echo "<a href=?page=".($page+1).">下一页</a> | <a href=?page=".$pagecount.">最后一页</a>";
break;
}
echo "共有".$totalnum."条记录,共".$pagecount."页,";
?>
当前记录:第<?=($page-1)*$pagesize+1?>~~<?php
if(($page-1)*$pagesize+$pagesize<$totalnum){
echo ($pagesize+($page-1)*$pagesize)."条";
}
else{
echo $totalnum."条";
}
?>
<script language=javascript>
function go(){
var page=document.getElementById("page").value;
if(page==""){
page=1;
}
if(page><?=$pagecount;?>){
page=<?=$pagecount;?>;
}
window.location.href="test.php?page="+page;
}
</script>
<input type=text value=<?=$page;?> size=3 name=page id=page>
<input type=button onclick='go()' value="Go">
</body>