[Php]分页及表格样式

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;">&nbsp;操作用户列表</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;">&nbsp;<?=$rs["username"]?></td>
    <td width="14%" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;">&nbsp;<?=$rs["usersex"]?></td>
    <td width="23%" height="30" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;">&nbsp;<?=$rs["accounts"]?></td>
    <td width="63%" style="border-bottom:dotted #0000FF 1px; font-size:12px; color:#000099;">&nbsp;<?=$rs["useradd"]?></td>
  </tr>

<?  
}
?> 

<tr>
    <td height="36" colspan="4" align="right" style="font-size=12;">&nbsp;共<font color=red><?=ceil($amcount/10)?></font>页&nbsp;当前第<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>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值