IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Construction d'un formulaire


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Par défaut Construction d'un formulaire
    bonjour à tous,

    Je souhaite mettre en forme plusieurs formulaire avec un seul bouton envoi, ceci est-il possible?

    soit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
     
    <?php
    require('configuration.php');
    $nombreEntrees = mysql_query("SELECT id  FROM sondage ") or die(mysql_error());
    $numeroDuFormulaire = mysql_fetch_assoc($nombreEntrees);
    $id_formulaire = $numeroDuFormulaire;
     
    echo '<form method="post" name="sondage" >';
     
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='1'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '1'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '1'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
    echo'</form>';
    echo '<form method="post" name="sondage" >';
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='2'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '2'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '2'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    echo'</form>';
    echo '<br />';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="sondage"/>';
     
    echo '<br/>';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
    echo '<form method="post" name="sondage" >';
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='3'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '3'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '3'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
     
    echo '<br />';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="sondage"/>';
     
    echo '<br/>';
    echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
     
     
    echo'</form>';
    ?>
    mon probléme le script prend en compte que le dernier formulaire mais je souhaiterais qui prend en compte ensemble des votes
    merci d'avance

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    pour tu ne fais pas qu'un seul <form> ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Par défaut
    merci de ta réponse,
    je fais plusieurs <form> car chaque nouveau form correspond a une nouvelle question donc de nouvelle proposition a choisir .
    si je fais un seul form, je pourrais seulement faire un seul choix parmis toutes les proposition.
    sinon quelle serait la solution à mon problème?

    merci d'avance

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Tu peux tres bien faire un seule formulaire avec plusieurs questions : au lieu d'appeller toutes tes propositions "sondage", tu les appelles "sondage[id_de_la_question]" par exemple.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Par défaut
    merci, j'ai changé le script par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
     
    <?php
    require('configuration.php');
    $nombreEntrees = mysql_query("SELECT id  FROM sondage ") or die(mysql_error());
    $numeroDuFormulaire = mysql_fetch_assoc($nombreEntrees);
    $id_formulaire = $numeroDuFormulaire;
     
    echo '<form method="post" name="sondage" >';
     
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='1'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '1'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage[1]']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage[1]'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '1'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[1]' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[1]' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[1]' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[1]' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[1]' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
     
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='2'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '2'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage[2]']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage[2]'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '2'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[2]' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[2]' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[2]' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[2]' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[2]' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
     
    echo '<br />';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="sondage"/>';
     
    echo '<br/>';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
     
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage where id='3'    ";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    //On sélectionne le nombre de votes
    $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3,resultats4,resultats5 FROM sondage WHERE id = '3'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes et ip
    $ip = $_SERVER['REMOTE_ADDR'];
    $prop = "prop";
     
    $resultat = "resultats";
    $fin = false;
    if(isset($_POST['sondage[3]']))
    {
    	for($i = 1; $i <= 5 && !$fin; $i++)
    	{
    		if($_POST['sondage[3]'] == $prop . $i)
    		{
    			$votes[$resultat . $i] ++;
    			mysql_query("UPDATE sondage SET  " . $resultat . $i . " = '" . $votes[$resultat . $i] . "' WHERE id = '3'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    if ($infos['question'] != "")
    echo '<div class="archives">'.stripslashes($infos['question']).'</div>'.''. "";
    if ($infos['proposition1'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition1']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[3]' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition2'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition2']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[3]' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition3'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition3']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[3]' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition4'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition4']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[3]' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
    if ($infos['proposition5'] != "")
    echo  '<div class="date">'.stripslashes($infos['proposition5']).'</div>'.'<font style=" font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;">'.  "<input type='radio' name='sondage[3]' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/vert_gauche.gif">'.'<img src="img/sondage/vert.gif" height="14" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/> ' . round($pourcentage_r1) . "% (".$result["resultats1"].($result["resultats1"] > 1 ? ' votes' : ' vote').")</font>";
     
    echo '<br />';
    //echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="sondage"/>';
     
    echo '<br/>';
    echo '<input type="image" width="75" src="img/sondage/voter.gif"  name="submit !"/>';
     
     
    echo'</form>';
    ?>
    maintenant, je peux choisir les differents choix par rapport aux questions mais les update ne comptabilise 0 a chaque fois. vous avez une idée du pourquoi? une solution?

Discussions similaires

  1. construction d'un formulaire tableau
    Par Novice_vba dans le forum Access
    Réponses: 0
    Dernier message: 25/03/2014, 18h16
  2. [2.x] [Form] Requête dans la construction d'un formulaire
    Par Trezegoals dans le forum Symfony
    Réponses: 2
    Dernier message: 18/03/2013, 18h25
  3. [PEAR][HTML_QuickForm] Construction d'un formulaire
    Par robertjul dans le forum Bibliothèques et frameworks
    Réponses: 2
    Dernier message: 18/04/2008, 01h23
  4. [MySQL] Construction d'un formulaire
    Par hitch86 dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 27/07/2007, 09h24
  5. Conseil sur la construction d'un gros formulaire
    Par billout rm dans le forum InfoPath
    Réponses: 9
    Dernier message: 24/07/2007, 12h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo