I need to display the results of a short poll, and display the percentage of results for each option in each question.
I don't know how to calculate the total number of results for each option or how to calculate and display the percentage of each vote.
One of the questions asks for your favorite month. I used M1-M12 to represent the checked value for the months. Below is what I have for the results script so far.
Thanx muchly
<html>
<head>
<title>Your Favorites</title>
<style type="text/css">
<!--
.style1 {
color: #333399;
font: bold 24px Arial;
text-align: center;
}
.style2 {
color: #333399;
font: bold 14px Arial;
}
.style5 {
font-size: 16px;
color: #330099;
font-family: Arial;
}
(resizable=yes,width=450,height=620)
}
-->
</style>
</head>
<body>
<form action="Poll.html" method="get">
<p class="style1">Your Favorites !</p>
<strong>
<p class="style5"> Thank you participating in this poll. <br>
If any items are incomplete, please hit the back button and complete your submission. </p> </strong>
<br>
<?php
if ( $Flower == "" ) {
$error=true;
echo "Please vote for your favorite flower.";
} else {
echo "Your favorite flower is the: $Flower."; }
?>
<br><br>
<?php
if ( $Month == "" ) {
$error=true;Vote for your favorite month.";
} else {
echo "Your favorite month is: $Month."; }
?>
<br><br>
<?php
if ( $Sport== "" ) {
$error=true;
echo "Please vote for your favorite sport.";
} else {
echo "Your favorite sport is: $Sport."; }
?>
Below are the results for each Month option:
<?php
$Jantotal=0
While ($Month=M1) }
$Jantotal=sum($M1); }
$JanPercent=($Jantotal/(sum($M1));}
echo $JanPercent of people voted for January
January received $Jantotal votes
}
?>
<br>
<input type="Submit" value="BACK" name="Submit">
<br>
<p class="style5"> <strong>Thanks for your time.</strong> </p>
</form>
</body>
</html>