Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\myphp_www\PHPTutorial\WWW\tccgl\lscw_list.php on line 40
我的代码如下
<p>已有长期车位列表:</p>
<form id="form1" name="form1" method="post" action="">
  搜索:车位号:
  <input name="no" type="text" id="no" />
 
  <input type="submit" name="Submit" value="查找" />
</form>
<table width="100%" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#6699CC" style="border-collapse:collapse">  
  <tr>
    <td width="25" bgcolor="#EBE2FE">序号</td>
    <td width="94" bgcolor='#EBE2FE'>车位号</td>
    <td width="94" bgcolor='#EBE2FE'>位置</td>
    <td width="94" bgcolor='#EBE2FE'>价格</td>
 <td width="94" bgcolor='#EBE2FE'>状态</td>
    <td width="70" align="center" bgcolor="#EBE2FE">操作</td>
  </tr>
   <?php 
    $sql="select * from cqcw where 1=1";
  if ($_POST["no"]!="")
{
   $no=$_POST["no"];
   $sql=$sql." and no like '%$no%'";
}
  $sql=$sql." order by id desc";
  
$query=mysql_query($sql);
  $rowscount=mysql_num_rows($query);
  if($rowscount==0)
  {}
  else
  {
  $pagelarge=10;//每页行数;
  $pagecurrent=$_GET["pagecurrent"];
  if($rowscount%$pagelarge==0)
  {
$pagecount=$rowscount/$pagelarge;
  }
  else
  {
    $pagecount=intval($rowscount/$pagelarge)+1;
  }
  if($pagecurrent=="" || $pagecurrent<=0)
{
$pagecurrent=1;
}
 
if($pagecurrent>$pagecount)
{
$pagecurrent=$pagecount;
}
$ddddd=$pagecurrent*$pagelarge;
if($pagecurrent==$pagecount)
{
if($rowscount%$pagelarge==0)
{
$ddddd=$pagecurrent*$pagelarge;
}
else
{
$ddddd=$pagecurrent*$pagelarge-$pagelarge+$rowscount%$pagelarge;
}
} for($i=$pagecurrent*$pagelarge-$pagelarge;$i<$ddddd;$i++)
{
  ?>
  <tr>
    <td width="25"> <?php
echo $i+1;
?></td>
    <td> <?php echo mysql_result($query,$i,no);?></td>
<td> <?php echo mysql_result($query,$i,descs);?></td>
<td> <?php echo mysql_result($query,$i,price);?></td>
<td> <?php echo mysql_result($query,$i,states);?></td>
    
   
    <td width="70" align="center"><a href="del.php?id= <?php
echo mysql_result($query,$i,"id");
?>&tablename=cqcw" onclick="return confirm('真的要删除?')">删除</a> <a href="cqcw_updt.php?id= <?php
echo mysql_result($query,$i,"id");
?>">修改</a></td>
  </tr>
    <?php
}
}
?>
</table>
<p>以上数据共 <?php
echo $rowscount;
?>条,
  <input type="button" name="Submit2" onclick="javascript:window.print();" value="打印本页" />
</p>
<p align="center"><a href="cqcw_list.php?pagecurrent=1">首页</a>, <a href="cqcw_list.php?pagecurrent= <?php echo $pagecurrent-1;?>">前一页</a> ,<a href="cqcw_list.php?pagecurrent= <?php echo $pagecurrent+1;?>">后一页</a>, <a href="cqcw_list.php?pagecurrent= <?php echo $pagecount;?>">末页</a>, 当前第 <?php echo $pagecurrent;?>页,共 <?php echo $pagecount;?>页 </p><p>&nbsp; </p></body>
</html>麻烦高手回答下哪里错了。

解决方案 »

  1.   

     <?php 
    include_once 'conn.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><link rel="stylesheet" href="css.css" type="text/css">
    </head><body><p>已有停车管理列表:</p>
    <form id="form1" name="form1" method="post" action="">
      搜索:车位:
      <input name="no" type="no" id="bh" />
      车牌:
      <input name="carno" type="text" id="carno" />
      <input type="submit" name="Submit" value="查找" />
    </form>
    <table width="100%" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#6699CC" style="border-collapse:collapse">  
      <tr>
        <td width="25" bgcolor="#EBE2FE">序号</td>
        <td width="94" bgcolor='#EBE2FE'>车牌号</td>
        <td width="94" bgcolor='#EBE2FE'>车位号</td>
        <td width="94" bgcolor='#EBE2FE'>进入时间</td>
        <td width="94" bgcolor='#EBE2FE'>离开时间</td>
    <td width="167" bgcolor='#EBE2FE'>停车时长</td>
        <td width="167" bgcolor='#EBE2FE'>单价</td>
        <td width="204" bgcolor='#EBE2FE'>总金额</td>
        <td width="86" bgcolor='#EBE2FE'>状态</td>   
        <td width="70" align="center" bgcolor="#EBE2FE">操作</td>
      </tr>
       <?php 
        $sql="select * from tc where 1=1 and states='进入' ";
      if ($_POST["no"]!="")
    {
       $no=$_POST["no"];
       $sql=$sql." and no like '%$no%'";
    }
         if ($_POST["carno"]!="")
    {
       $carno=$_POST["carno"];
       $sql=$sql." and carno like '%$carno%'";
    }
      $sql=$sql." order by id desc";
      
    $query=mysql_query($sql);
      $rowscount=mysql_num_rows($query);
      if($rowscount==0)
      {}
      else
      {
      $pagelarge=10;//每页行数;
      $pagecurrent=$_GET["pagecurrent"];
      if($rowscount%$pagelarge==0)
      {
    $pagecount=$rowscount/$pagelarge;
      }
      else
      {
        $pagecount=intval($rowscount/$pagelarge)+1;
      }
      if($pagecurrent=="" || $pagecurrent<=0)
    {
    $pagecurrent=1;
    }
     
    if($pagecurrent>$pagecount)
    {
    $pagecurrent=$pagecount;
    }
    $ddddd=$pagecurrent*$pagelarge;
    if($pagecurrent==$pagecount)
    {
    if($rowscount%$pagelarge==0)
    {
    $ddddd=$pagecurrent*$pagelarge;
    }
    else
    {
    $ddddd=$pagecurrent*$pagelarge-$pagelarge+$rowscount%$pagelarge;
    }
    } for($i=$pagecurrent*$pagelarge-$pagelarge;$i<$ddddd;$i++)
    {
      ?>
      <tr>
        <td width="25"> <?php
    echo $i+1;
    ?></td>
        <td> <?php echo mysql_result($query,$i,carno);?></td>
    <td> <?php echo mysql_result($query,$i,no);?></td>
    <td> <?php echo mysql_result($query,$i,btimes);?></td>
    <td> <?php echo mysql_result($query,$i,etimes);?></td>
    <td> <?php echo mysql_result($query,$i,hour);?></td>
    <td> <?php echo mysql_result($query,$i,price);?></td>
    <td> <?php echo mysql_result($query,$i,totle);?></td>
    <td> <?php echo mysql_result($query,$i,states);?></td>

       
       
        <td width="70" align="center"><a href="del.php?id= <?php
    echo mysql_result($query,$i,"id");
    ?>&tablename=tc" onclick="return confirm('真的要删除?')">删除</a> <a href="tc_updt.php?id= <?php
    echo mysql_result($query,$i,"id");
    ?>">离开</a></td>
      </tr>
        <?php
    }
    }
    ?>
    </table>
    <p>以上数据共 <?php
    echo $rowscount;
    ?>条,
      <input type="button" name="Submit2" onclick="javascript:window.print();" value="打印本页" />
    </p>
    <p align="center"><a href="yonghuzhuce_list.php?pagecurrent=1">首页</a>, <a href="yonghuzhuce_list.php?pagecurrent= <?php echo $pagecurrent-1;?>">前一页</a> ,<a href="yonghuzhuce_list.php?pagecurrent= <?php echo $pagecurrent+1;?>">后一页</a>, <a href="yonghuzhuce_list.php?pagecurrent= <?php echo $pagecount;?>">末页</a>, 当前第 <?php echo $pagecurrent;?>页,共 <?php echo $pagecount;?>页 </p><p>&nbsp; </p></body>
    </html>