Voila je suis en train de coder la partie ou l'on enregistrer les votes de mon sondage. Mais la je trouve vraiment que c'est barbare:
Avez vous une autre solution?
Code:
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){
$champ1= 'resultat1 + 1';
$champ2= 'resultat2 + 0';
$champ3= 'resultat3 + 0';
$champ4= 'resultat4 + 0';
}
if($_POST['reponse'] == 2){
$champ2= 'resultat2 + 2';
$champ1= 'resultat1 + 0';
$champ3= 'resultat3 + 0';
$champ4= 'resultat4 + 0';
}
if($_POST['reponse'] == 3){
$champ3= 'resultat3 + 3';
$champ1= 'resultat1 + 0';
$champ2= 'resultat2 + 0';
$champ4= 'resultat4 + 0';
}
if($_POST['reponse'] == 4){
$champ4= 'resultat4 + 4';
$champ2= 'resultat4 + 0';
$champ3= 'resultat3 + 0';
$champ1= 'resultat1 + 0';
}
$save_vote = doquery("UPDATE {{table}} SET resultat1= '".$champ1."', resultat2= '".$champ2."', resultat3= '".$champ3."', resultat4= '".$champ4."' WHERE id='".$vote['id']."'", "sondage");
Avez vous une autre solution?