我得到一个资源ID#作为结果。使用myphpadmin时,查询返回正确的计数。 我已经尝试过使用mysql_fetch_assoc和mysql_fetch_row但我无法让它工作。 可以使用一些指导。谢谢。
$casenumber= ($rows['case_number']); //stores this rows case number
$casecount = "SELECT COUNT(case_number) AS `total`
FROM `vekt6_chronoforms_data_CaseJuryPool`\n"
. "WHERE vekt6_chronoforms_data_CaseJuryPool.case_number = '{$casenumber}'";
$num = mysql_query($casecount);
echo $num; // result of case numbers count
答案 0 :(得分:3)
您忘了取结果
$res = mysql_query($casecount);
$row = mysql_fetch_assoc($res);
echo $row['total'];
Please, don't use mysql_*
functions in new code。它们不再被维护and are officially deprecated。请参阅red box?转而了解prepared statements,并使用PDO或MySQLi - this article将帮助您确定哪个。如果您选择PDO here is a good tutorial。