我有这个.php,我必须从数据库中计算最大投票数
SELECT std.fname, std.lname, COUNT(v.cand_id)
FROM vote v, student std, candidate ca, position pos
WHERE v.cand_id = ca.stud_id AND ca.pos_id = 1 AND ca.stud_id = std.id
问题是计数已关闭,它显示 70 票,而当我在数据库中计数时,它只有 11 票。我认为这是计算所有选票,而不是计算COUNT(v.cand_id)
.
这张表是关于计算选票并显示获得选票的最高人。
$que1 = mysql_query ($sql1,$con);
while($row1 = mysql_fetch_array($que1))
{
echo "President: "; echo "".$row1['fname']; echo " ".$row1['lname']; echo " having ".$row1['v.cand_id']; echo " votes";
echo "<br>";
}