<?
@require_once('../inc/fun.inc.php');
@require_once('../inc/config.db.php');
@require_once('cookie.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<table width="50%" border="0" cellpadding="5" cellspacing="1" bgcolor="#000000">
  <tr>
    <td colspan="3" align="center" style="color:#FFF; font-size:16px; font-weight:bold">分类管理</td>
  </tr>
  <tr>
    <td width="23%" height="24" align="center" bgcolor="#FFFFFF">编号</td>
    <td width="58%" align="center" bgcolor="#FFFFFF">分类名称</td>
    <td width="19%" align="center" bgcolor="#FFFFFF">操作</td>
  </tr>
  <?
  $sql = "select * from cplb order by id desc";
  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
  $pagenum = 1;
  $sumpage = ceil($num/$pagenum);
  $page = $_GET["page"];
  if(empty($page) || !ereg("^[1-9[0-9]]*$",$page) || $page > $sumpage)
  {
	  $page = 1;
  }
  $srtartnum = ($page-1)*$pagenum;
  $sql = "select * from cplb order by id desc limit $srtartnum,$pagenum";
  $result = mysql_query($sql);
  while($row = mysql_fetch_array($result))
  {
  ?>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><?=$row["id"]?></td>
    <td align="center" bgcolor="#FFFFFF"><?=$row["name"]?></td>
    <td align="center" bgcolor="#FFFFFF"><a href="admin.php?main=cplb_up&id=<?=$row["id"]?>">编辑</a>|<a href="admin.php?main=cplb_dele&id=<?=$row["id"]?>">删除</a></td>
  </tr>
  <?
  }
  ?>
  <tr>
    <td colspan="3" align="center" bgcolor="#FFFFFF">
    <? if($num == 0){echo "暂时无数据";?><? }else{?>总共<?=$sumpage?>页
    <a href="<? $_SERVER['PHP_SELF']?>?main=cplb">首页</a>&nbsp;<a href="<? $_SERVER['PHP_SELF']?>?main=cplb&page=<?=$page-1?>">上一页</a>&nbsp;<a href="<? $_SERVER['PHP_SELF']?>?main=cplb&page=<?=$page+1?>">下一页</a>
    <a href="<? $_SERVER['PHP_SELF']?>?main=cplb&page=<?=$sumpage?>">尾页</a><? }?>
    </td>
  </tr>
</table>
<table width="50%">
  <tr>
    <td align="center"><a style="text-decoration:none; color:#000; font-size:15px" href="admin.php?main=cplbadd">添加分类</a></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>