<?
@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="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#000000">
  <tr>
    <td colspan="6" align="center" bgcolor="#000000" style="color:#FFF; font-size:16px; font-weight:bold">新闻列表</td>
  </tr>
  <tr>
    <td width="8%" align="center" bgcolor="#FFFFFF">编号</td>
    <td width="41%" align="center" bgcolor="#FFFFFF">标题</td>
    <td width="13%" align="center" bgcolor="#FFFFFF">作者</td>
    <td width="13%" align="center" bgcolor="#FFFFFF">来源</td>
    <td width="14%" align="center" bgcolor="#FFFFFF">添加时间</td>
    <td width="11%" align="center" bgcolor="#FFFFFF">操作</td>
  </tr>
  <?
  $sql = "select * from news order by id desc";
  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
  $pagenum = 10;
  $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 news 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["title"]?></td>
    <td align="center" bgcolor="#FFFFFF"><?=$row["author"]?></td>
    <td align="center" bgcolor="#FFFFFF"><?=$row["source"]?></td>
    <td align="center" bgcolor="#FFFFFF"><?=$row["time"]?></td>
    <td align="center" bgcolor="#FFFFFF"><a href="admin.php?main=news_up&id=<?=$row["id"]?>">编辑</a>|<a href="admin.php?main=news_del&id=<?=$row["id"]?>">删除</a></td>
  </tr>
  <?
  }
  ?>
  <tr>
    <td colspan="6" align="center" bgcolor="#FFFFFF">
    <? if($num == 0){echo "暂时无数据";?><? }else{?>总共<?=$sumpage?>页
    <a href="<? $_SERVER['PHP_SELF']?>?main=newsadmin">首页</a>&nbsp;<a href="<? $_SERVER['PHP_SELF']?>?main=newsadmin&page=<?=$page-1?>">上一页</a>&nbsp;<a href="<? $_SERVER['PHP_SELF']?>?main=newsadmin&page=<?=$page+1?>">下一页</a>
    <a href="<? $_SERVER['PHP_SELF']?>?main=newsadmin&page=<?=$sumpage?>">尾页</a><? }?>
    </td>
  </tr>
</table>
</body>
</html>