鍍金池/ 問答/PHP/ php7.0下 查詢符合條件的數(shù)量

php7.0下 查詢符合條件的數(shù)量

<?php @session_start();?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php if($_SESSION["uid"]==""){echo "<script>alert('對不起,您還沒有登陸!');window.location.href='../login.php';</script>";exit;}
require_once('../../func/dbase.php');
error_reporting(E_ALL ^ E_NOTICE);
?>
<title>下載中心管理</title>
<?php
  $end= 0;
  $countPage = 0;
  $count = 0;
  $page = 0;
  $result =0;
  $end = 0;
  $classid = 0;
  $page = $_GET['page'];
  if($page==''){$page=1;}
  $torul = 20;
  $start = $page * $torul - $torul;
  $id = '';
  $re = 0;
  $id = $_GET['id'];
    $key = $_POST['key'];
   $lei = $_POST['lei'];
  if($id!=''){
      $sql="select id,url from down where id=".$id;
    $result = $mysqli->query($sql);
    while($rs=mysqli_fetch_array($result)){unlink("../../down/$rs[1]");}
    $sql = "delete from down where id =".$id;
    $result = $mysqli->query($sql);
    if($re!=0){
       echo "<script>window.location =index.php?page=".$page."</script>";
    }
  }
if($_REQUEST['act']=='delall'){
$yy=$_REQUEST['xx'];
for($i=0;$i<count($yy);$i++){
$sql="select id,url from down where id=".$yy[$i];
$result = $mysqli->query($sql);
while($rs=mysqli_fetch_array($result)){unlink("../../down/$rs[1]");}
$sql= "delete from down where id=".$yy[$i];
$result = $mysqli->query($sql);}
echo "<script>window.location.href='index.php?page=$page';</script>";
exit;}?>

<style type="text/css">
<!--
td {
    font-size: 12px;
}
-->
</style>
<link href="../css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #007EC0;
}
-->
</style>
<script language="javascript">
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
}
</script>
</head>
<body>
<table width="0" height="28" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="48"><img src="../images/44_1.jpg" width="10" height="48" alt="" /></td>
    <td background="../images/44_2.jpg"><span style="font-size:16px">下載中心管理&gt;&gt;</span></td>
    <td width="11"><img src="../images/44_4.jpg" width="11" height="48" alt="" /></td>
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="36"><img src="../images/44_5.jpg" width="10" height="36" alt="" /></td>
    <td background="../images/44_6.jpg">&nbsp;</td>
    <td width="11"><img src="../images/44_8.jpg" width="11" height="36" alt="" /></td>
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="450" background="../images/44_9.jpg">&nbsp;</td>
    <td valign="top" bgcolor="#FFFFFF">
<form name="form1" method="post" action="index1.php">
        <table width="560" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr><td></td></tr></table>
        <table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="193" height="25">&nbsp;關(guān)鍵字
              <input name="key" type="text" id="key" value="<?php echo $key?>" size="20" maxlength="30"></td>
            <td width="214" align="center"><select name="lei">
                <option value="0">---所有分類---</option>
<option value="1">軟件</option>
<option value="2">用戶手冊</option>
<option value="3">產(chǎn)品圖冊</option>
              </select>
            </td>
            <td width="153" valign="bottom">&nbsp;
                <input type="submit" name="Submit" value="搜 索" style="width:60px; height:25px;"></td>
          </tr>
        </table>
      </form>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#f8f8f8" style="border:1px solid #3366dd">
  <form name="form1" action="index.php" method="post">
  <tr>
    <td width="94" height="30" align="center"  >選/否
    <input type="checkbox" id="chkall" name="chkall" value="on" onClick="CheckAll(this.form)"></td>
    <td width="555" align="left"  >&nbsp;名稱</td>
    <td width="98" align="center"  >類別</td>
    <td width="101" align="center"  >時間</td>
    <td colspan="2" align="center" >操作</td>
  </tr>
   <?php
     $sql = "select id,title,left(sdate,10) sdate,lei from down";
     if($key!=''){
     $sql= $sql." and  title like '%".$key."%'";
     }
     if($lei>0){
             $sql = $sql." and lei = ".$lei;
     }
     $sql = $sql." order by id desc";
     $sql = $sql." limit ".$start.",".$torul;
          
     $result = $mysqli->query($sql);
     while($ar=mysqli_fetch_row($result)){$count =  $ar[0];}

    $result = $mysqli->query($sql);
    if($count<$torul&&$count>0){$page = 1;}

    if(($count%$torul)==0){
        $countPage = intval($count/$torul);
    } else {
        $countPage = intval($count/$torul) +1;
    }
     if($result!=0){
        while($arr=mysqli_fetch_array($result)){
        $i++;
        if($i%2==0){$bg="#f5f5f5";}
        else{$bg="#ffffff";}?>
   <tr>
    <td width="94" height="22" align="center" bgcolor="<?php echo $bg;?>"><input type="checkbox" name="xx[]" value="<?php echo $arr[0];?>"></td>
    <td height="22" align="left" bgcolor="<?php echo $bg;?>">&nbsp;<?php echo $arr[1]?></td>
    <td height="22" align="center" bgcolor="<?php echo $bg;?>">&nbsp;
    <?php if($arr[3]==1){?>軟件<?php }?>
    <?php if($arr[3]==2){?>用戶手冊<?php }?>
    <?php if($arr[3]==3){?>產(chǎn)品圖冊<?php }?></td>
    <td align="center" bgcolor="<?php echo $bg;?>">&nbsp;<?php echo $arr[2];?></td>
    <td width="53" height="22" align="center" bgcolor="<?php echo $bg;?>"><a href="add.php?id=<?php echo $arr[0]?>">修改</a></td>
    <td width="60" height="22" align="center" bgcolor="<?php echo $bg;?>"><a href="?id=<?php echo $arr[0]?>&page=<?php echo $page?>"  onClick="return confirm('確定刪除嗎?')">刪除</a></td>
  </tr>
   <?php }}if($count==0){?>
  <tr>
    <td  height="300" colspan="6" align="center" bgcolor="#FFFFFF" class="zz" >暫無相關(guān)信息!</td>
  </tr>
    <?php }?>
  <tr align="center">
    <td height="25" colspan="7" bgcolor="#f7f7f7">
    <a href="?page=1">首頁</a>
    <?php if($page>1){?>
    <a href="?page=<?php echo ($page - 1)?>">上一頁</a><?php }?>
    - <?php echo $page?> -
    <?php if($countPage>$page){?>
    <a href="?page=<?php echo ($page+1)?>">下一頁</a><?php }?>
    <a href="?page=<?php echo $countPage?>">尾頁</a>    共<?php echo $countPage?>頁, 共<?php echo $count?>條文章
    <input type="submit" onClick="return confirm('是否刪除選擇的信息?')" name="Submit2" value="刪 除">
(刪除所選)
<input name="act" type="hidden" id="act" value="delall"></td>
  </tr>
  </form>
</table>
    </td>
    <td width="11" background="../images/44_11.jpg">&nbsp;</td>
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="26"><img src="../images/44_12.jpg" width="10" height="26" alt="" /></td>
    <td background="../images/44_13.jpg">&nbsp;</td>
    <td width="11"><img src="../images/44_15.jpg" width="11" height="26" alt="" /></td>
  </tr>
</table>
</body>
</html>

現(xiàn)在就是統(tǒng)計條數(shù)那不準,哪位大蝦幫下忙
while($ar=mysqli_fetch_row($result)){$count = $ar[0];}

回答
編輯回答
凹凸曼

不太懂題主的意思, 不過你要是想限制查詢的數(shù)量的話 , 可以在后面加一個limit

2017年12月17日 21:08
編輯回答
旖襯

就是求符合條件的記錄數(shù),總共有幾條

2018年7月18日 13:47