<?php
 session_start();
 include("conn/conn.php");
 include("top.php");
?>
<style type="text/css">
<!--
.style1 {color: #990000}
-->
</style>

<table width="766" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="229" valign="top" bgcolor="#F0F0F0"><?php include("left.php");?></td>
    <td width="561" align="center" valign="top" bgcolor="#FFFFFF"><table width="550" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
      <?php
         $jdcz=$_POST[jdcz];
         $name=$_POST[name];
        if($jdcz!="" or isset($_GET[name]) ){
            if (isset($_GET[name])) { $name = $_GET[name];}
         $sql1=mysql_query("select count(*) as total  from tb_shangpin where mingcheng like '%".$name."%'",$conn);
         $info1=mysql_fetch_array($sql1);
         $total=$info1[total];
         $pagesize=10;
           if ($total<=$pagesize){
              $pagecount=1;
            }
            if(($total%$pagesize)!=0){
               $pagecount=intval($total/$pagesize)+1;
           
            }else{
               $pagecount=$total/$pagesize;
           
            }
            if(($_GET[page])==""){
                $page=1;
           
            }else{
                $page=intval($_GET[page]);
           
            }
         $sql=mysql_query("select * from tb_shangpin where mingcheng like '%".$name."%' order by addtime desc limit ".($page-1)*$pagesize.",$pagesize",$conn);
        }
         $info=mysql_fetch_array($sql);
         if($info==false){
           echo "<script language='javascript'>alert('本站暂无类似产品!');history.go(-1);</script>";
          }
         else{
    ?>
      <table width="530" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="#FFEDBF">
          <td width="99" height="25"><div align="center" style="color: #990000">名称</div></td>
          <td width="56"><div align="center" style="color: #990000">剩余数量</div></td>
          <td width="44"><div align="center" style="color: #990000">单位</div></td>
          <td width="159"><div align="center" style="color: #990000">规格</div></td>
          <td width="71"><div align="center" style="color: #990000">上架时间</div></td>
          <td width="46"><div align="center" style="color: #FFFFFF"><span class="style1"></span></div></td>
          <td width="47"><div align="center" style="color: #990000">操作</div></td>
        </tr>
        <?php
         do{
        ?>
        <tr bgcolor="#FFFFFF">
          <td height="25"><div align="center"><?php echo $info[mingcheng];?></div></td>
          <td height="25"><div align="center"><?php echo $info[shuliang];?></div></td>
          <td height="25"><div align="center"><?php echo $info[xinghao];?></div></td>
          <td height="25"><div align="center"><?php echo $info[jianjie];?></div></td>
          <td height="25"><div align="center"><?php echo $info[addtime];?></div></td>
          <td height="25"><div align="center"><a href="lookinfo.php?id=<?php echo $info[id];?>">查看</a></div></td>
          <td height="25"><div align="center"><a href="addgouwuche.php?id=<?php echo $info[id];?>" onClick="javascript:history.back();">领用</a></div></td>
        </tr>
        <?php   
           }while($info=mysql_fetch_array($sql));
         }
        ?>
    </table>
    <table width="530" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><div align="right"> &nbsp;共有该类商品&nbsp;
                  <?php
           echo $total;
          ?>
&nbsp;件&nbsp;每页显示&nbsp;<?php echo $pagesize;?>&nbsp;件&nbsp;第&nbsp;<?php echo $page;?>&nbsp;页/共&nbsp;<?php echo $pagecount; ?>&nbsp;页
        <?php
          if($page>=2)
          {
          ?>
        <a href="findsp.php?name=<?php echo $name;?>&page=1" title="首页"><font face="webdings"> 9 </font></a> <a href="findsp.php?name=<?php echo $name;?>&page=<?php echo $page-1;?>" title="前一页"><font face="webdings"> 7 </font></a>
        <?php
          }
                  if($pagecount<=4){
                   for($i=1;$i<=$pagecount;$i++){
          ?>
        <a href="findsp.php?name=<?php echo $name;?>&page=<?php echo $i;?>"><?php echo $i;?></a>
        <?php
             }
           }else{
           for($i=1;$i<=4;$i++){     
          ?>
        <a href="findsp.php?name=<?php echo $name;?>&page=<?php echo $i;?>"><?php echo $i;?></a>
        <?php }?>
        <a href="findsp.php?name=<?php echo $name;?>&page=<?php echo $page+1;?>" title="后一页"><font face="webdings"> 8 </font></a> <a href="findsp.php?name=<?php echo $name;?>&page=<?php echo $pagecount;?>" title="尾页"><font face="webdings"> : </font></a>
        <?php }?>
          </div></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<?php
 include("bottom.php");
?>