comment puis-je obtenir le résultat de ma requête COUNT.comment obtenir la valeur comptée
c'est à quoi il ressemble de ma requête dans ma base de données
fname lname mname positionName COUNT(tbl_votes.studId)
jr gwapo is-very chairman 2
et voilà comment ma page Web ressemble
Name Position Number of Votes
jr is-very gwapo chairman ______
et Heres mon code.
<?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 mon problème, comment pourrais-je passer le "comte (tbl_votes.studId)" dans "echo "" $ ligne-> ??? ".";"? pls help ...
@VladPreda merci beaucoup pour fixer l'empreinte dans la question. –
Pas de problème. Je vous recommande d'utiliser un IDE qui le fait automatiquement. Je viens de le copier et de le recopier :) –
à tous ..thnks pour répondre ... –