query($sql);
$numsel = $result->num_rows;
$counter = 0;
while( $counter < $numsel) {
$row = $result->fetch_assoc();
$cnumber[] = $row["subid"];
$odesc[] = $row["items"];
$counter = $counter + 1;
}
$sql = "select aid, nick, decision from voteattend where decision > 0 and tvalid = 1 ";
$result = $conn->query($sql);
$num = $result->num_rows;
$counter = 0;
$subv = [0,0,0];
$j = 0;
echo "";
echo " | 票號 | 匿名號 | 投票 | | ";
while( $j < $numsel) {
echo "".$odesc[$j]." | ";
$j = $j + 1;
}
echo "
";
while( $counter < $num) {
// Extract one row into an array
$row = $result->fetch_assoc();
$a = $row["decision"] - 1;
$subv[$a] = $subv[$a] + 1;
$j = 0;
while( $j < $numsel) {
$p[$j] = "".$subv[$j].$odesc[$j];
$j = $j + 1;
}
echo "| ".$row["aid"]." | ".$row["nick"]." | ".$odesc[$a]." | | ";
$j = 0;
while( $j < $numsel) {
echo "".$p[$j]." | ";
$j = $j + 1;
}
echo "
";
$counter = $counter + 1;
}
echo "
";
echo "";
$j = 0;
while( $j < $numsel) {
echo "'".$odesc[$j]."'共有".$subv[$j]."票 ";
$j = $j + 1;
}
echo "
";
$j = 0;
while( $j < $numsel) {
$overall = $overall + $subv[$j];
$j = $j + 1;
}
echo "
共有投票 ".$overall." 張
";
echo '
';
$conn->close();
?>