<?php 
session_start(); 
include ("conn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>管理新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body,td,th {
font-size: 14px;
color: #999999;
font-family: 宋体;
}
a:link {
text-decoration: none;
color: #FF0000;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: none;
color: #FFCC00;
}
a:active {
text-decoration: none;
}
body {
background-image: url(img/h_bj.jpg);
background-repeat: no-repeat;
}
.STYLE1 {color: #FF0000}
-->
</style><body ><TABLE width="700" cellPadding=0 cellSpacing=0  > 
  <TBODY> 
  &nbsp;&nbsp;&nbsp;&nbsp;<b><a href="add_news.php" class="STYLE1">[发布新闻]</a></b> 
        <tr>
  <table width="700" height="500"  align="center" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="130" align="center" valign="top" ><?php if ($page=="") {$page=1;}; ?>
<table width="700" border="0" align="center" cellpadding="3" >
                 <?php
if ($page){
   $page_size=15;                                           //每页显示20条记录
   $query="select count(*) as total from news";            //查询数据库所有记录
$result=mysql_query($query);                            //查询总的记录条数
$message_count=mysql_result($result,0,"total");         //为变量赋值
$page_count=ceil($message_count/$page_size);         //根据记录总数除以每页显示的记录数求出所分的页数
$offset=($page-1)*$page_size;                 //计算下一页从第几条数据开始循环  
$sql=mysql_query("select * from news order by id  desc limit $offset, $page_size");
$info=mysql_fetch_array($sql);
?>
                <tr>
                  <td height="30" align="center"  valign="top" >
  <table width="650"  border="0" cellspacing="0" cellpadding="0"  >
  <tr><td height="5"></td>
  </tr>
  <tr>
  <td>
  <h3>新闻管理</h3>
  </td>
  </tr>
                    <tr>
                      <td >
  <table width="620"  border="1" cellspacing="0" cellpadding="0" valign="top" >
                       <tr>
  <td width="75%" align="center">
  新闻标题
  </td>
   <td width="15%">
   发布时间
  </td>
   <td width="10%" align="center">
   操作
  </td>
  </tr>
                          <?php
   if($info){
$i=1;
do{
  ?>
                          <tr>
                            <td width="70%" align="left" valign="top">
<a href="showmanager_news.php?id=<?php echo $info[id];?>" title="查看新闻">
<?php echo $i."、&nbsp;".$info[title];?></a></td>
<td width="20%" align="center" ><?php echo$info[now];?></td>
<td width="!0%" align="center"><a href="del_news.php?id=<?php echo $info[id];?>">
<!--删除新闻 -->
                        <img src="../Admin/img/A_delete.gif" width="52" height="16"   onclick="javascript:if (confirm('您确定要删除吗?注意:此操作不可恢复,请谨慎操作!')){return true;} return false;" border="0"></a></td>
                          </tr>
                          <?php 
  $i=$i+1;
  }while($info=mysql_fetch_array($sql))
  ?>
                      </table>
  </td>
                    </tr>
                  </table></td>
                </tr>
               <?php } ?>
              </table>
              <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr  align="left">
                  <td width="50%">&nbsp;&nbsp;&nbsp;&nbsp;页次:<?php echo $page;?>/<?php echo $page_count;?>页&nbsp;记录:<?php echo $message_count;?> 条</td>
                  <td width="50%" align="right">
                          <?php
  if($page!=1)
   {
 echo  "<a href=manager_news.php?page=1>首页</a>&nbsp;";
 echo "<a href=manager_news.php?page=".($page-1).">上一页</a>&nbsp;";
   }
  if($page<$page_count)
   {
echo "<a href=manager_news.php?page=".($page+1).">下一页</a>&nbsp;";
echo  "<a href=manager_news.php?page=".$page_count.">尾页</a>";
   }
 } 
?>
                  </td>
                </tr>
              </table></td>
          </tr>
        </table>
</table></TD> 
    </TR> 
  </TBODY> 
</TABLE> 
</body>
</html>