我一直试图根据几个post方法参数来计算SQL表中的行数,因此,我已经能够连接到数据库并编写了用于计数的代码,但是以某种方式不是返回任何内容,邮递员窗口为空白,这意味着连接成功,但不知何故,
<?php
//checking if the script received a post request or not
if($_SERVER['REQUEST_METHOD']=='POST'){
//Getting post data
$match_id=$_POST['match_id'];
$rs=$_POST['rs'];
require_once('connect.php');
$sql = "select count(1) From OneRecord where match_id='$match_id' and
rs='$rs'";
if($result=mysqli_query($con,$sql)){
$row = mysql_fetch_array($result);
$total = $row[0];
echo "Total rows: " . $total;
}
else
{
echo 'oops! Please try again!';
}
mysqli_close($con);
}
?>
答案 0 :(得分:0)
<?php
//checking if the script received a post request or not
if($_SERVER['REQUEST_METHOD']=='POST'){
//Getting post data
$match_id=$_POST['match_id'];
$rs=$_POST['rs'];
require_once('connect.php');
$sql = "select * From OneRecord where match_id='$match_id' and rs='$rs'";
if($result=mysqli_query($con,$sql)){
// Return the number of rows in result set
$rowcount=mysqli_num_rows($result);
printf(" %d rows.\n",$rowcount);
// Free result
mysqli_free_result($result);
}
else
{
echo 'oops! Please try again!';
}
mysqli_close($con);
}
?>