<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
$limit=5;//每页显示的记录数
$start=intval($_REQUEST["page"]);
if (empty($start))
$start=1;
$page=$start;
$start=$start-1;
$start=$start*$limit;
$recordcound=$recount/$limit;
$sqlrs="select * from news where Putout order by addtime desc limit $start,$limit";
$sqlrs2="select * from news where Putout order by addtime desc";
$result=mysql_query($sqlrs,$conn);
if($_SESSION["flag"]<>1)
//采用缓存存放记录总数
{
$result2=mysql_query($sqlrs2,$conn);
$recount= mysql_num_rows($result2);
$_SESSION["flag"]=1;
$_SESSION["recordcoundflag"]=$recount;
}
//计算总页数
$paycount=(int)($recount/ $limit)+1;
while($rs=mysql_fetch_array($result))
{
?>
<tr>
<td width="6%" height="30" align="center">·</td>
<td width="94%"><?php echo $rs["Newtitle"];?></td>
</tr>
<?php
}
?>
<tr>
<td height="27" colspan="2" align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" align="right">
<?php
$webpag="newslist.php";//翻页在哪一页进行
?>
共<?php echo $_SESSION["recordcoundflag"]; ?>条记录 第<?php echo $page;?>/<?php echo $paycount;?>页 每页<?php echo $limit;?>条 <a href="<?php echo $webpag;?>">首页</a>
<?php
if ((int)($page)<>1 )
{
?>
<a href="<?php echo $webpag;?>?page=<?php if (($page-1)<=0)
echo "1";
else
echo $page-1;
?>">上页</a>
<?php
}
if ((int)($page)<$paycount)
{
?><a href="<?php echo $webpag."?page=".($page+1);?>">下页</a>
<?php }?>
<a href="<?php echo $webpag."?page=".$paycount;?>">末页</a> 转到第
<select name=""onChange="javascript:location=this.options[this.selectedIndex].value;">
<?php for ($i=1;$i<=$paycount;$i++)
{
?>
<option value="<?php echo $webpag."?page=".$i;?>"><?php echo $i."页"?>
<?php }?>
</select></td>
</tr>
</table> </td>
</tr>
</table>