クエリ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();
?>
heres my problem, how could i pass the "Count(tbl_votes.studId)" in "echo "" . $row-> ??? . ""; " ? pls help...