投票現況

query($sql); $num = $result->num_rows; $counter = 0; $yes = 0; $no = 0; $giveup = 0; $nselect = 0; $po = ""; $ne = ""; $mi = ""; echo ""; echo " "; while( $counter < $num) { // Extract one row into an array $row = $result->fetch_assoc(); if($row["decision"]==1) { $yes = $yes + 1; $choice = "贊成"; $mi = "有".$giveup."票無意見"; $ne = "有".$no."票反對"; $po = "有".$yes."票贊成"; echo ""; $counter = $counter + 1; } elseif($row["decision"]==2) { $no = $no + 1; $choice = "反對"; $mi = "有".$giveup."票無意見"; $ne = "有".$no."票反對"; $po = "有".$yes."票贊成"; echo ""; $counter = $counter + 1; } elseif($row["decision"]==3) { $giveup = $giveup + 1; $choice = "棄權"; $mi = "有".$giveup."票無意見"; $ne = "有".$no."票反對"; $po = "有".$yes."票贊成"; echo ""; $counter = $counter + 1; } else { $nselect = $nselect + 1; $choice = "未輸入"; $counter = $counter + 1; } } echo "
匿名號投的票是贊成票反對票無意見票
".$row["nick"]."".$choice."$po$ne$mi
".$row["nick"]."".$choice."$po$ne$mi
".$row["nick"]."".$choice."$po$ne$mi
"; echo "

贊成的共有 ".$yes." 票, 反對的共有 ".$no." 票, 無意見的共有 ".$giveup." 票

"; $overall = $yes + $no + $giveup; echo "

共有投票 ".$overall." 張

"; echo '

'; echo ''; ?>