我从一张表中执行了 4 次计数查询。但我从所有查询中得到相同的输出。但实际值与表中不同。
这是我的 table 。
ID || notify_type || status
__________________________________________
1 || resume_uploaded || 1
这是我的疑问:
$notify_query1 = "select count(*) from notify where status = 1 and notify_type = 'resume_uploaded'";
$row1 = mysqli_query($db_manager->connection,$notify_query1);
$rcount = mysqli_num_rows($row1);
$notify_query2 = "select count(*) from notify where status = 1 and notify_type = 'detail_filled'";
$row2 = mysqli_query($db_manager->connection,$notify_query2);
$dcount = mysqli_num_rows($row2);
$notify_query3 = "select count(*) from notify where status = 1 and notify_type = 'job_detailed'";
$row3 = mysqli_query($db_manager->connection,$notify_query3);
$jcount = mysqli_num_rows($row3);
$notify_query4 = "select count(*) from notify where status = 1 and notify_type = 'msg_sent'";
$row4 = mysqli_query($db_manager->connection,$notify_query4);
$mcount = mysqli_num_rows($row4);
我从所有四个查询中获取输出1: 请帮助我。
最佳答案
使用fetch_row()
而是 mysqli_num_rows()
。
$result = $db->query("select count(*) from notify where status = 1 and notify_type = 'resume_uploaded'");
$row = $result->fetch_row();
echo 'No of count: '. $row[0];
关于php - 如何在php中执行多个计数查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34504986/