Voila actuellement j'arrive a faire fonctionner mon sondage de cette mannière, mais le code me semble quand meme assez répétitif sur certains points. Je sais pas trop comment faire pour améliorer le code
//Affichage du sondage.
$query = doquery ("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 0,1", "sondage");
$vote = mysql_fetch_array($query);
if (!empty($vote['question']))
{
$question = '<img width="16px" height="15px" alt="" src="images/login/question.gif" style="vertical-align: middle;"/> <span class="marron2"><b>'.stripslashes($vote['question']).'</b></span><br /><br />';
$bouton = '<div style="text-align: center" ><input type="image" src="images/login/bouton_voter.gif" class="no_bordure" title="Voter" name="sondage"/></div>';
}else
{
$question = '<span class="marron2"><b>Aucun sondage</b></span>';
$bouton = '';
}
$id = $vote['id'];
$sondage = '
'.$question.'';
if (!isset($_POST["sondage_x"]))
{
if(!empty($vote['reponse1']))
{
$sondage .= '<input type="radio" value="1" name="reponse" checked> '.stripslashes($vote['reponse1']).'<br />';
}
if(!empty($vote['reponse2']))
{
$sondage .= '<input type="radio" value="2" name="reponse"> '.stripslashes($vote['reponse2']).'<br />';
}
if(!empty($vote['reponse3']))
{
$sondage .= '<input type="radio" value="3" name="reponse"> '.stripslashes($vote['reponse3']).'<br />';
}
if(!empty($vote['reponse4']))
{
$sondage .= '<input type="radio" value="4" name="reponse"> '.stripslashes($vote['reponse4']).'<br />';
}
$sondage .= '<br />'.$bouton.'</div></form>';
}else
{
if($_POST['reponse'] == 1) { $update1= 'resultat1 = resultat1 + 1'; }
if($_POST['reponse'] == 2) { $update1= 'resultat2 = resultat2 + 1'; }
if($_POST['reponse'] == 3) { $update1= 'resultat3 = resultat3 + 1'; }
if($_POST['reponse'] == 4) { $update1= 'resultat4 = resultat4 + 1'; }
$save_vote = doquery("UPDATE {{table}} SET $update1 WHERE id='".$vote['id']."'", "sondage");
$insert_ip = doquery("INSERT INTO {{table}} SET numero='".$vote['id']."', ip='".$_SERVER['REMOTE_ADDR']."'", "sondage_ip");
$sondage = 'Vote enregistré ('.$_POST['reponse'].')</div></form>';
}