我已使用phpMyAdmin验证了我的查询。计数是130.但是我的代码给了我一个计数。
$query2 = "SELECT COUNT(*) FROM webvulns";
$result2 = mysqli_query($connection, $query2);
confirm_query($result2);
$rowcount=mysqli_num_rows($result2);
echo $rowcount;
// Free result set.
mysqli_free_result($result2);
答案 0 :(得分:2)
mysqli_num_rows
返回行数。你只有1排。该行中将包含130
。获取结果。
$query2 = "SELECT COUNT(*) as da_count FROM webvulns";
$result2 = mysqli_query($connection, $query2);
confirm_query($result2);
$row = mysqli_fetch_assoc($result2);
$rowcount=$row['da_count'];
echo $rowcount;
// Free result set.
mysqli_free_result($result2);
答案 1 :(得分:0)
试一试,它会正常工作
$query2 = "SELECT COUNT(*) FROM webvulns";
$result2 = mysqli_query($connection, $query2);
$row = mysqli_fetch_array($result, MYSQLI_NUM);
echo $row[0];