我如何从我的查询COUNT中得到结果。如何获得计数值
这是它的外观我查询我的数据库
fname lname mname positionName COUNT(tbl_votes.studId)
jr gwapo is-very chairman 2
,这是我的网页看起来如何
Name Position Number of Votes
jr is-very gwapo chairman ______
和继承人我的代码。
<?php
if ($result = $mysqli->query("SELECT tbl_student.fname, tbl_student.lname, tbl_student.mname, tbl_position.positionName, Count(tbl_votes.studId) FROM tbl_candidate Inner Join tbl_student ON tbl_candidate.studId = tbl_student.studId Inner Join tbl_position ON tbl_candidate.positionId = tbl_position.positionId Inner Join tbl_votes ON tbl_student.studId = tbl_votes.candId WHERE tbl_position.positionId = '1' GROUP BY tbl_student.fname, tbl_student.lname, tbl_student.mname, tbl_position.positionName")) {
if ($result->num_rows > 0) {
echo "<table border='1' cellpadding='10'>";
// set table headers
echo "<tr><th>Name</th><th>Position</th><th>Number of Votes</th></tr>";
while ($row = $result->fetch_object()) {
echo "<tr>";
echo "<td>" . $row->fname . " " . $row->mname . " " . $row->lname . " </td>";
echo "<td>" . $row->positionName . "</td>";
//this is where i suppose to echo the count result
echo "<td>" . $row-> ??? . "</td>";
echo"<tr>";
}
echo "</table>";
} else {
echo "No results to display!";
}
}
$mysqli->close();
?>
我的继承人问题,我怎么能传递 “伯爵(tbl_votes.studId)” 在 “回声 ”“ $按行> ??? ”“;”?请帮助...
@VladPreda感谢很多在固定的缩进题。 –
没问题。我建议您使用自动执行此操作的IDE。我只是在那里复制它,并将其复制回来:) –
to all ..thunk回应... –