打印本文 打印本文  关闭窗口 关闭窗口
PHP+MYSQL的文章管理系统(二)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 14:29:59
###############index.php######################
<?session_start();
require"./inc/func.php";
mscon();
require "./inc/header.inc";
?>
<script language="javascript">
function opwin(filename)
{                window.open("read_article.php?id="+filename,"","height=500,width=585,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
        }

</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#003399" height="23">
  <tr>
    <td width="80">
      <div id="Layer2" style="position:absolute; left:7px; top:17px; width:43px; height:44px; z-index:2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="80" height="60">
          <param name=movie value="images/logo.swf">
          <param name=quality value=high>
          <param name="wmode" value="transparent">
          <embed src="images/logo.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="80" height="60" wmode="transparent">
          </embed>
        </object></div>
      <div id="Layer1" style="position:absolute; left:-5px; top:61px; width:49px; height:37px; z-index:1"><img src="images/11.gif" width="58" height="55"></div>
    </td>
    <td width="539"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="468" height="60">
          <param name=movie value="images/ti1.swf">
          <param name=quality value=high>
          <param name="wmode" value="transparent">
          <embed src="images/ti1.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60" wmode="transparent">
          </embed>

      </object> </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td background="images/211.gif" height="2">&nbsp;</td>
  </tr>
</table>
<table><FORM name=form1 action=search.php  method=post target=_blank>
  <table width="80%" border="0" cellspacing="0" cellpadding="0" bgcolor="#009933" align="center">
    <tr>
    <td align="center">
    <input type="text" name="key">
  <select name="type">
  <option value=>全部类别</option>
<? $typ=file("list.txt");
$num=count($typ);
for($i=2;$i<=$num;$i++)
{
  echo"<option value=$typ[$i]>$typ[$i]</option>";}
      ?>
  </select>
  <select name="whe">
  <option value=>全部内容</option>
  <option value=1>文章内容</option>
  <option value=2>文章标题</option>
  <option value=3>加入时间</option>
  </select>
  <input type="hidden" name="submit" value="1">
  <input type="submit" name="submit" value="提交查询">
  </td>
  </tr>
</table>
</FORM></table>
<?
$type=trim($type);
  if($comm)
    {
     $sec="and comm=1";
     $fir="where comm=1";
    }
  if(!empty($type))
    $query="select count(*) from $table where type='$type' $sec";
  else
    $query="select count(*) from $table $fir";
  $res=mysql_db_query("$database",$query);
  if(@mysql_num_rows($res)>0)
    $tot=mysql_fetch_array($res);
  $total=$tot[0];
  $total_page=ceil($total/$pagenum);
  echo "<table width="80%" border="0" cellspacing="0" cellpadding="0" align=center>";
  echo "<tr><td>共:".$total."篇".$total_page."页</td></tr>";
  if(empty($page))
    $page=0;
  if(empty($offset))
    $offset=0;
  $offset=$pagenum*$page;
  if(!empty($type))
     $query="select * from $table where type='$type' $sec order by id desc limit $offset,$pagenum";
  else
    $query="select * from $table $fir order by id desc limit $offset,$pagenum";
  $res=mysql_db_query("$database",$query);
  if(@mysql_num_rows($res)>0)
     while($topic=mysql_fetch_array($res))
       {
         if(strlen($topic[title])>40)
          {
            $topic[title]=substr($topic[title],0,40) ;
            $topic[title]=$topic[title].".....";
          }
         if(trim($topic[time])==date(Y年m月d日))
           $topic[time]="<font color=#FF9900>$topic[time]</font>";
           echo" <tr><td>[$topic[type]]<a href=# onClick="opwin($topic[id])";>$topic[title]</a><font size=1>($topic[time])</font>";
        if($topic[comm]==1)
          echo "<img src="./images/comm.gif" alt="精品文章">";
        if($topic[locked]==1)
          echo "<img src="./images/locked.gif" alt="文章已锁定">";
        echo "</td>
          <td>阅读:$topic[hits] 次;评论:$topic[p_num]次</td>
          </tr>";
     }
else
   echo " 对不起,本栏 目暂没有任何文章!!!";
echo "</table>";
  ?>

<br>
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
  <?
     $pre=$page-1;
     $next=$page+1;
if($page>0)
   echo "<a href="$php_self?page=$pre&type=$type">上一页</a><br><br>";
else
  echo "上一页<br><br>";  ?></td>
    <td><?if($page<$total_page-1)
   echo "   <a href="$php_self?page=$next&type=$type">下一页</a><br><br>";
else echo "   下一页<br><br>";?&g

[1] [2] [3]  下一页



打印本文 打印本文  关闭窗口 关闭窗口