writer:web wu 2007/11/29
这个分页代码比较简单一些.
<style type="text/css">
<!--
a:link {
color: #990000;
text-decoration: none;
}
a:visited {
color: #990000;
text-decoration: none;
}
a:hover {
color: #990000;
}
a:active {
color: #FF0000;
text-decoration: none;
}
-->
</style>
<table width="38%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #000099;">
<tr>
<td height="30" colspan="4" align="center" style="color:#ffffff;font-size:14;background:#0000FF;"> 操作用户列表</td>
</tr>
<?
include "conn.php"; //连接数据库文件
mysql_select_db("admin"); //打开数据表
$ssql=mysql_query("select count(*) as amcount from alluser",$con); //统计记录数
if($myrow=mysql_fetch_array($ssql))
{
$amcount=$myrow["amcount"];
}
if(empty($_GET['page']))
{
$page=0; //页数为0而给值0
}
else
{
$page=$_GET['page'];
if($page<0)
{
$page=0;
}
if($page>=ceil($amcount/10))
{
$page=ceil($amcount/10)-1; //判断页数
}
}
$sql=mysql_query("select * from alluser limit ".($page*10).",10",$con);
while($rs=mysql_fetch_array($sql)) //输出部分
{
?>
<tr οnmοuseοver="this.style.background='#FFFFCC';" οnmοuseοut="this.style.background='#FFFFFF';">
<td width="23%" height="30" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;"> <?=$rs["username"]?></td>
<td width="14%" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;"> <?=$rs["usersex"]?></td>
<td width="23%" height="30" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;"> <?=$rs["accounts"]?></td>
<td width="63%" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;"> <?=$rs["useradd"]?></td>
</tr>
<?
}
?>
<tr>
<td height="36" colspan="4" align="right" style="font-size=12;"> 共<font color=red><?=ceil($amcount/10)?></font>页 当前第<font color=red><?=$page+1?></font>页
<?
if($page>0)
{
?>
<a href="?page=0">首页</a>
<a href="?page=<?=$page-1?>">上页</a>
<?
}
else
{
echo "<font color=gray>首页 上页</font>";
}
if($page<ceil($amcount/10)-1)
{
?>
<a href="?page=<?=$page+1?>">下页</a>
<a href="?page=<?=ceil($amcount/10)-1?>">尾页</a> </td>
<?
}
else
{
echo "<font color=gray>下页 尾页</font>";
}
?>
</tr>
</table>