(ff poll geüpdated, want 'k heb hem al iets lager kunne maken!)
Zou er iemand weten wat er fout is aan mijn poll?
Het probleem is: als je al de resultaten optelt kom je aan meer dan 100% :s
<?
if($actie == "Vote") {
mysql_connect("lycos.nl","voetbalgame","");
mysql_select_db("voetbalgame_nl_db");
$invoer = "UPDATE poll SET stem$stem = stem$stem+1,totaal = totaal+1 WHERE vraag = 'Hoe vind je de layout van het forum?'";
$query = mysql_query($invoer) or die (mysql_error());
echo "<b>Stem toegevoegd!</b><br>";
}
function procent($getal,$totaal) {
$ant = 100/$totaal;
$pro = $ant*$getal;
return $pro;
}
mysql_connect("***","***","***");
mysql_select_db("***");
$sql = "SELECT * FROM poll";
$sql = mysql_query($sql) or die (mysql_error());
while($poll = mysql_fetch_array($sql)) {
$pro[1] = procent($poll[stem1],$poll[totaal]);
$pro[2] = procent($poll[stem2],$poll[totaal]);
$pro[3] = procent($poll[stem3],$poll[totaal]);
$img[1] = round($pro[1]);
$img[2] = round($pro[2]);
$img[3] = round($pro[3]);
echo "<form>
$poll[vraag]<br><br>
<table style='border: 1px solid'>
<tr><td><input type='radio' name='stem' value='1'>$poll[antwoord1] ($poll[stem1] stemmen) <img src='poll.gif' height='15' width='$img[1]'> ($img[1]%)</td></tr>
<tr><td><input type='radio' name='stem' value='2'>$poll[antwoord2] ($poll[stem2] stemmen) <img src='poll.gif' height='15' width='$img[2]'> ($img[2]%)</td></tr>
<tr><td><input type='radio' name='stem' value='3'>$poll[antwoord3] ($poll[stem3] stemmen) <img src='poll.gif' height='15' width='$img[3]'> ($img[3]%)</td></tr>
<tr><td><input type='submit' name='actie' value='Vote'></td></tr>
</table><br>
Totaal aantal stemmen: $poll[totaal]
</form>";
}
?>
1.026 views