mon code ets bon ou pas ?
<?
$IDSONDAGE = 3;
mysql_connect("localhost","maxnickealbroacker","")
;
mysql_select_db("nightmareonweb_db");
$retour = mysql_query(" SELECT * FROM sondage WHERE id=" .$IDSONDAGE. " ");
$donnees = (mysql_fetch_array($retour));
?>
<table width="180" border="0" cellpadding="0" cellspacing="0" class="Style1" style="font-family:Arial, Helvetica, sans-serif">
<tr>
<td class="Style1"><div align="center" class="LEFT"><? echo $donnees[´question´]; ?> </div></td>
</tr>
<tr>
<td class="Style1" style="font-family:Arial, Helvetica, sans-serif">
<form method="post" action="Sondage.php">
<input type="radio" value="reponse1" name="sond1"/>
<? echo $donnees[´reponse1´]; ?> <br />
<input type="radio" value="reponse2" name="sond1"/>
<? echo $donnees[´reponse2´]; ?> <br />
<input type="radio" value="reponse3" name="sond1"/>
<? echo $donnees[´reponse3´]; ?> <br />
<div align="center">
<input type="submit" value="Voter" />
</div>
</form></td>
</tr>
<tr>
<td class="Style1" style="font-family:Arial, Helvetica, sans-serif"><span class="Style1" style="color:#00FF00 ">
<?
if(isset($_POST[´sond1´]))
{
if($_POST[´sond1´] != NULL)
{
switch($_POST[´sond1´])
{
case ´reponse1´;
$idvote = ´votes1´;
break;
case ´reponse2´;
$idvote = ´votes2´;
break;
case ´reponse3´;
$idvote = ´votes3´;
break;
}
// On enregistre le vote :
$vote1 = mysql_query("SELECT " .$idvote. " FROM sondage WHERE id=" .$IDSONDAGE. "");
$donnees2 = mysql_fetch_array($vote1);
$vote2 = $donnees2[´´ .$idvote. ´´];
$vote3 = ($vote2 + 1); // On ajoute 1 au total
echo ´Ceci est le ´ .$vote3. ´e vote pour cette question !< br />´;
mysql_query("UPDATE sondage WHERE id=" .$IDSONDAGE. " SET " .$idvote. "=" .$vote3. " ");
}
}
// On compte les votes :
$LesVotes = mysql_query("SELECT * FROM sondage WHERE id=" .$IDSONDAGE. " ");
$donnees3 = mysql_fetch_array($LesVotes);
$TotalDeVotes = ($donnees3[´votes1´] + $donnees3[´votes2´]);
echo ´Il y a deja ´ .$TotalDeVotes. ´ personnes qui ont voté(e)s !< br />´;
// On met les pourcentages :
// On rappelle que % c´est LESVOTES * 100 / TOTALDESVOTES
$pourcent1 = ($donnees3[´votes1´] * 100 / $TotalDeVotes);
$pourcent2 = ($donnees3[´votes2´] * 100 / $TotalDeVotes);
$pourcent3 = ($donnees3[´votes3´] * 100 / $TotalDeVotes);
echo ´Pourentages de Votes : <br /> Reponse 1 : ´ .$pourcent1. ´%<br /> Reponse 2 : ´ .$pourcent2. ´%<br /> Reponse 3 : ´ .$pourcent3. ´%´;
mysql_close();
?>
</td></tr></table>