<?php   
  //数据库设置   
  $mysqlhost   =   "localhost"; //数据库主机名   
  $mysqluser   =   "a"; //数据库用户名   
  $mysqlpass   =   "b"; //数据库密码   
  $mysqldb       =   "c"; //数据库名   
  $mysqltb       =   "d"; //数据表名   
    
  //分页设置   
  $limit           =   "20"; //每页显示记录数   
    
    
  /**   
    *程序区   
    *   
    **/   
  if   ($search_key)   {   
  $link   =   @mysql_pconnect($mysqlhost,$mysqluser,$mysqlpass)   or   die("连接数据库失败!");   
  @mysql_select_db($mysqldb,$link);   
  if   (!$pg)   {   
  $pg   =   "0";   
  }   
  //搜索   
  $sresult   =   @mysql_query("SELECT   *   FROM   $mysqltb   WHERE   type0='".$type_sel."'   AND   (softname   LIKE   '%".$search_key."%'   OR   rlsgroup   LIKE   '%".$search_key."%')   ORDER   BY   id   DESC   LIMIT   $pg,$limit",$link);   
    
  //获得总数   
  $numresult   =   @mysql_query("SELECT   *   FROM   $mysqltb   WHERE   (softname   LIKE   '%".$search_key."%'   OR   rlsgroup   LIKE   '%".$search_key."%')   AND   type0='".$type_sel."'",$link);   
  $num   =   @mysql_num_rows($numresult);   
  @mysql_free_result($numresult);   
    
  //显示页   
  $page   =   fepage($PHP_SELF."?search_key=$search_key&type_sel=$type_sel",$num);   
    
    
            
  }   
    
  /**   
    *分页   
    *   
    **/   
  function   fepage($path,$pnum)     
  {     
  global   $limit,$pg;     
  if   ($pnum   <=   $limit)   {     
  $page   =   "只有一页";     
  }     
  else   {     
  if   (!$pg   ||   ($pg   <=   "0"))   {     
  $page   =   "上一页   |   "."<a   href=".$path."&pg=".($pg   +   $limit)."><FONT   COLOR=\"ff0000\">下一页</FONT></a>";     
  }   elseif   (($pg   +   $limit)   >=   $pnum)   {     
  $page   =   "<a   href=".$path."&pg=".($pg   -   $limit)."><FONT   COLOR=\"ff0000\">上一页</FONT></a>   |   "."下一页</a>";     
  }   else   {     
  $page   =   "<a   href=".$path."&pg=".($pg   -   $limit)."><FONT   COLOR=\"ff0000\">上一页</FONT></a>   |   "."<a   href=".$path."&pg=".($pg   +   $limit)."><FONT   COLOR=\"ff0000\">下一页</FONT></a>";     
  }     
  }     
  return   $page;     
    
  }   //   end   func     
    
  ?>   
  <html>   
  <head>   
  <title>搜索</title>   
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
  <style   type="text/css">   
  <!--   
  td   {     font-size:   12px}   
  -->   
  </style>   
  <script   language='javascript'>   
  <!--   
  function   check()   
  {   
  if(document.searchform.search_key.value=='')   
  {   
  alert("请输入您要搜索的关键字.");   
  document.searchform.search_key.focus();   
  return   false;   
  }   
  if(document.searchform.type_sel.value=='-1')   
  {   
  alert("请选择相应的类型.");   
  document.searchform.type_sel.focus();   
  return   false;   
  }   
  }   
  -->   
  </script>   
  </head>   
    
  <body   bgcolor="#FFFFFF"   text="#000000">   
  <table   width="100%"   border="0"   cellspacing="1"   cellpadding="2">   
              <form   name="searchform"   method="post"   action="<?=$PHP_SELF?>"   onsubmit="return   check()">   
      <tr>     
          <td>   
              <input   type="text"   name="search_key">
              <select   name="type_sel">
                <option   value="-1"   selected>选择类型</option>
                <option   value="were">名称</option>
              </select>
              <input   type="submit"   name="send"   value="开始搜索">          </td>   
      </tr>   
              </form>   
      <tr>   
          <td>搜索结果(共<font   color="ff0000"><b>   <?=$num;?></b></font>   条)</td>   
      </tr>   
      <tr>   
          <td>   
              <table   width="100%"   border="0"   align="center"   bgcolor="#CCCCCC"   cellspacing="1"   cellpadding="3">   
                  <tr   bgcolor="#FFFFFF">     
                      <td   height="13"   width="14%">DATE</td>   
                      <td   height="13"   width="21%">SOFTNAME</td>   
                      <td   height="13"   width="10%">Rls   GROUP</td>   
                      <td   height="13"   width="8%">   TYPE</td>   
                      <td   height="13"   width="9%">SIZE</td>   
                      <td   height="13"   width="38%">URL</td>   
                  </tr>   
    
  <?php   
  while   ($row   =   @mysql_fetch_array($sresult))   {   
            
  ?>   
<tr   bgcolor="#FFFFFF">     
                      <td   width="14%"><?=$row ["were"];?></td>   
                      <td   width="21%"><?=$row ["were"];?></td>   
                      <td   width="10%"><?=$row ["were"];?></td>   
                      <td   width="8%"><?=$row ["were"];?></td>   
                      <td   width="9%"><?=$row ["were"];?></td>   
                      <td   width="38%"><?=$row ["were"];?></td>   
                  </tr>  
    
  <?php   
  }     
  @mysql_free_result($sresult);   
  ?>   
      </table>          </td>   
      </tr>   
      <tr>   
          <td   align="center"><?=$page;?></td>   
      </tr>   
      <tr>   
          <td>&nbsp;</td>   
      </tr>   
  </table>   
  <!--   
  <table   width="100%"   border="0">   
      <tr>     
          <td   align="center">提示信息</td>   
      </tr>   
      <tr>   
          <td   align="center"   height="65">$msg<br>   
              <br>   
              <a   href="<?=$PHP_SELF?>">请返回</a></td>   
      </tr>   
      <tr>   
          <td>&nbsp;</td>   
      </tr>   
  </table>   
  -->   
  </body>   
  </html>