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

EDI, CMS, Outils, Scripts et API PHP Discussion :

fonctionnalité sondage php


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #41
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Tu as des guillemets qui se balladent.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $sql = "INSERT INTO $table1 (sondage_id, vote_ip) VALUES ($sondage_id, $vote_ip)";
    Par contre le "Array" doit venir de la version ou tu avais
    $sondage_id = $numeroDuSondage;
    avec $sondage_id = $numeroDuSondage['nbre_entrees']; tu dois avoir un numéro.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    j'ai bien un numero.
    j'ai erreur suivante:
    Erreur SQL !
    INSERT INTO t_vote (sondage_id, vote_ip) VALUES (7, 127.0.0.1)
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.1)' at line 1

    pk? que faut-il faire?

    merci beaucoup de ton aide

  3. #43
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Fiou je suis pas en forme moi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $sql = "INSERT INTO $table1 (sondage_id, vote_ip) VALUES ($sondage_id, '$vote_ip')";
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    merci beaucoup
    j'ai encore des problemes

    maintenant a chaque fois nouverau sondage, il reconnait ip donc empeche le vote

    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
     
    $query = "SELECT * FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "' " ;
    //echo("<br />" . $query . "<br />");
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    if($num)
    {
    if ($infos['question'] != "")
    echo $infos['question'].'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo $infos['proposition1'].'<br/>'. "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
     
    	if ($infos['proposition2'] != "")
    			       echo $infos['proposition2'].'<br/>'. "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
    if ($infos['proposition3'] != "")
    				       echo $infos['proposition3'].'<br/>'. "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r3) . "% </label><br />";
     
    	if ($infos['proposition4'] != "")
    			       echo $infos['proposition4'].'<br/>'. "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="black.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
         if ($infos['proposition5'] != "")
    	 			       echo $infos['proposition5'].'<br/>'. "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="blue.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    exit;
    }
    $vote_ip = $_SERVER['REMOTE_ADDR'];
    $sondage_id = $numeroDuSondage['nbre_entrees'];
    $sql = "INSERT INTO $table1 (sondage_id, vote_ip) VALUES ($sondage_id, '$vote_ip')";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    mais pourquoi, que faut-il faire please

  5. #45
    Membre expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Points : 3 972
    Points
    3 972
    Par défaut
    Yop,

    dans le code que tu montres, il n'y a pas la partie qui est chargée de vérifier si une personne a déjà voté ou non.

    D'autres parts, il y a un exit qui se balade, exit arrête l'execution d'un script et donc empeche l'execution de ton INSERT INTO.

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    merci beaucoup de votre aide.
    pour ma derniére question, j'ai réussi par moi-même, pour ceux qui suivrait ce grand tutoriel voici le script mis en place

    script:
    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
     
    $query = "SELECT vote_ip FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "'  " ;
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    if($num)
    {
    if ($infos['question'] != "")
    echo $infos['question'].'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo $infos['proposition1'].'<br/>'. "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
     
    	if ($infos['proposition2'] != "")
    			       echo $infos['proposition2'].'<br/>'. "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
    if ($infos['proposition3'] != "")
    				       echo $infos['proposition3'].'<br/>'. "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r3) . "% </label><br />";
     
    	if ($infos['proposition4'] != "")
    			       echo $infos['proposition4'].'<br/>'. "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="black.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
         if ($infos['proposition5'] != "")
    	 			       echo $infos['proposition5'].'<br/>'. "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="blue.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    exit;
    }
    $vote_ip = $_SERVER['REMOTE_ADDR'];
    $sondage_id = $numeroDuSondage['nbre_entrees'];
    $sql = "INSERT INTO $table1 (sondage_id, vote_ip) VALUES ($sondage_id, '$vote_ip')";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    j'ai un autre problème:
    je souhaiterais mettre en place un sondage multilingue, soit mettre un sondage par rapport a la langue du visiteur?
    mais comment faire?

    merci pour ceux qui voudront bien m'aidé

  7. #47
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Indique nous le code que tu as déjà réalisé sur la gestion des langues avec les réponseq qui t'ont déjà été donnée et nous pourrons t'aider sur les points qui te bloquent encore.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    justement, je suis un peu bloqué au démarrage.

    la table sql:
    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
    CREATE TABLE `sondage` (
    `id` SMALLINT NOT NULL AUTO_INCREMENT,
    ip char(50),
    lang char(50),
    `question` TEXT NOT NULL ,
    `proposition1` VARCHAR( 100 ) NOT NULL ,
    `proposition2` VARCHAR( 100 ) NOT NULL ,
    `proposition3` VARCHAR( 100 ) NOT NULL ,
    `proposition4` VARCHAR( 100 ) NOT NULL ,
    `proposition5` VARCHAR( 100 ) NOT NULL ,
    `resultats1` SMALLINT NOT NULL ,
    `resultats2` SMALLINT NOT NULL ,
    `resultats3` SMALLINT NOT NULL ,
    `resultats4` SMALLINT NOT NULL ,
    `resultats5` SMALLINT NOT NULL ,
    PRIMARY KEY ( `id` )
    ) ENGINE = InnoDB
    script:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    $lang= $_SERVER["HTTP_ACCEPT_LANGUAGE"];
    $query = "SELECT * FROM ".$table." WHERE lang='$lang'";
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    $sql = "INSERT INTO $table and sondage_id (lang) VALUES ('$lang') ";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    je sais pas trop, comment gerer la gestion des langue à affichage

  9. #49
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Il va falloir que tu réorganises ta base.

    Moi je verrais :

    t_sondage :
    sondage_id
    sondage_question

    t_proposition :
    propos_id
    sondage_id
    propos_numero (numero de la question dans le sondage)
    propos_lang
    propos_resultat

    Les propositions du sondage 145 en allemand ca serait donc :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT * FROM t_proposition WHERE sondage_id = 145 AND propos_lang = 'DE'
    Les resultats de la question 1 du sondage 145 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT sum(propos_resultat) WHERE sondage_id = 145 AND propos_numero = 1
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    ok je note c interessant mais le probleme c'est que je n'ai plus le temps de tout refaire. enfin sauf si t'en a pour 30 minute a 1h maxi et la je te dis je suis preneur

    donc j'aimerais ajouter la langue avec la base actuelle c possible?
    ou comme pour t_vote?

    mais en gardant la base en resultat et proposition

    sinon, je suis preneur pour tu me montre tt ca

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    j'ai un probleme avec ma page archive des sondage:
    je n'arrive pas à afficher les resultats de sondage par rapport à id

    voici le script:

    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
    <form method="post" action="archive.php">
    <p>
    Sondages archivés :
    <select name="archive">
            <?php
            require('configuration.php');
            //on crée une liste déroulante avec les questions des sondages effectués
    	$reponseMySQL = mysql_query("SELECT id, question FROM sondage") or die(mysql_error());
            while ($infos = mysql_fetch_assoc($reponseMySQL))
    	{
            echo "<option value=\"" . $infos['id'] . "\">" . $infos['question'] . "</option>";
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive"/>
    </p>
    </form>
    
    <?php
    // pourcentage des votes en moide graphique et compte
    // On recupere les nombre total de votes resultat1
    $query = "SELECT resultats1,resultats2,resultats3,resultats4, resultats5 FROM ".$table." WHERE id="."'" . $numeroDuSondage['nbre_entrees'] . "'
    $row = mysql_query($query);
    $data = mysql_fetch_array($row);
    $resultat1 = $data["resultats1"];
    $resultat2 = $data["resultats2"];
    $resultat3 = $data["resultats3"];
    $resultat4 = $data["resultats4"];
    $resultat5 = $data["resultats5"];
    
    $total_votes = $resultat1 + $resultat2 + $resultat3 + $resultat4 + $resultat5;
    if($total_votes != 0){
        $pourcentage_r1 = ($resultat1 / $total_votes) * 100;
        $pourcentage_r2 = ($resultat2 / $total_votes) * 100;
        $pourcentage_r3 = ($resultat3 / $total_votes) * 100;
        $pourcentage_r4 = ($resultat4 / $total_votes) * 100;
        $pourcentage_r5 = ($resultat5 / $total_votes) * 100;
    }
    else{
        $pourcentage_r1 = 0;
        $pourcentage_r2 = 0;
        $pourcentage_r3 = 0;
    	$pourcentage_r4 = 0;
    	$pourcentage_r5 = 0;
    }
    
    
    
    $long_max_bloc = 120; // longueur maximale du curseur pour un vote en pixels
    
    if (isset($_POST['archive']))
    {
            //on selectionne les infos sur notre choix
    	$MySQL_archive = mysql_query("SELECT * FROM sondage WHERE id='" . $_POST['id'] . "'") or die(mysql_error());
    	$archive = mysql_fetch_assoc($MySQL_archive);
    
            //on affiche la question, les propositions et le nombre de votes
    	echo $archive['question'] . "<br/>";
    	echo $archive['proposition1'] . "  =>  " . $archive['resultats1'] .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
    	echo $archive['proposition2'] . "  =>  " . $archive['resultats2'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
    	echo $archive['proposition3'] . "  =>  " . $archive['resultats3'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r3).'%" />.' . round($pourcentage_r3) . "% </label><br />"; ?>
    <?php
            //on fait les tests habituels pour verifier la présences d'autres propositions
    	 if ($archive['proposition4'] != "")
    	 		echo $archive['proposition4'] . "  =>  " . $archive['resultats4'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
    	 	if ($archive['proposition5'] != "")
    	 		echo $archive['proposition5'] . "  =>  " . $archive['resultats5'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    	 }
    
    
    ?>
    si qqn voit ou est erreur donc la partie en gras je pense, quelle modification?

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    pour mon probleme de langue ceci est réglé, merci de votre aide.

    j'aimerais obtenir votre aide sur mon problème archivage:

    j'arrive qu'a obtenir le premier id et tous les autres se dirigeant vers celui-ci, comment faire, pour obtenir id selon la question? je vous met le script et dites moi ce que vous trouvez anormal, toute suggestion sont bonne à prendre

    script archives:
    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
     
    <form method="post" action="archive.php">
    <p>
    Sondages archivés :
    <select name="archive">
            <?php
            require('configuration.php');
            //on crée une liste déroulante avec les questions des sondages effectués
    	$reponseMySQL = mysql_query("SELECT id, question FROM sondage") or die(mysql_error());
            while ($infos = mysql_fetch_assoc($reponseMySQL))
    	{
            echo "<option value=\"" . $infos['id'] . "\">" . $infos['question'] . "</option>";
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive"/>
    </p>
    </form>
     
    <?php
    // pourcentage des votes en moide graphique et compte
    // On recupere les nombre total de votes resultat1
    $query = "SELECT resultats1,resultats2,resultats3,resultats4, resultats5 FROM ".$table." WHERE id="."12";
    $row = mysql_query($query);
    $data = mysql_fetch_array($row);
    $resultat1 = $data["resultats1"];
    $resultat2 = $data["resultats2"];
    $resultat3 = $data["resultats3"];
    $resultat4 = $data["resultats4"];
    $resultat5 = $data["resultats5"];
     
    $total_votes = $resultat1 + $resultat2 + $resultat3 + $resultat4 + $resultat5;
    if($total_votes != 0){
        $pourcentage_r1 = ($resultat1 / $total_votes) * 100;
        $pourcentage_r2 = ($resultat2 / $total_votes) * 100;
        $pourcentage_r3 = ($resultat3 / $total_votes) * 100;
        $pourcentage_r4 = ($resultat4 / $total_votes) * 100;
        $pourcentage_r5 = ($resultat5 / $total_votes) * 100;
    }
    else{
        $pourcentage_r1 = 0;
        $pourcentage_r2 = 0;
        $pourcentage_r3 = 0;
    	$pourcentage_r4 = 0;
    	$pourcentage_r5 = 0;
    }
     
     
     
    $long_max_bloc = 120; // longueur maximale du curseur pour un vote en pixels
     
    if (isset($_POST['archive']))
    {
            //on selectionne les infos sur notre choix
    	$MySQL_archive = mysql_query("SELECT * FROM sondage WHERE id='" . $_POST['id'] . "'") or die(mysql_error());
    	$archive = mysql_fetch_assoc($MySQL_archive);
     
            //on affiche la question, les propositions et le nombre de votes
    	echo $archive['question'] . "<br/>";
    	echo $archive['proposition1'] . "  =>  " . $archive['resultats1'] .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
    	echo $archive['proposition2'] . "  =>  " . $archive['resultats2'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
    	echo $archive['proposition3'] . "  =>  " . $archive['resultats3'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r3).'%" />.' . round($pourcentage_r3) . "% </label><br />"; ?>
    <?php
            //on fait les tests habituels pour verifier la présences d'autres propositions
    	 if ($archive['proposition4'] != "")
    	 		echo $archive['proposition4'] . "  =>  " . $archive['resultats4'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
    	 	if ($archive['proposition5'] != "")
    	 		echo $archive['proposition5'] . "  =>  " . $archive['resultats5'].'<img src="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    	 }
     
     
    ?>
    merci de votre aide

  13. #53
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Ta question n'est vraiment pas clair.
    Reformule la en decrivant precisemment ca que tu as et ce que tu veux.
    Et montre nous seulement la partie du code concernée.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    merci pour la réponse,
    mon probléme est le script affiche seulement et uniquement le premier sondage dans la table mysql. je souhaiterais qui m'affiche le sondage séléctionner par le formulaire et qui m'affiche le résultat

    voici le code:

    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
     
    <!-- debut formulaire -->
    <form method="post" action="archive.php">
    <p>
    Sondages archivés :
    <select name="archive">
            <?php
            require('configuration.php');
            //on crée une liste déroulante avec les questions des sondages effectués
    	$reponseMySQL = mysql_query("SELECT id, question FROM $table ") or die(mysql_error());
            while ($infos = mysql_fetch_assoc($reponseMySQL))
    	{
            echo "<option value=\"" . $infos['id'] . "\">" . $infos['question'] . "</option>";
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive"/>
    </p>
    </form>
    <!-- fin formulaire -->
    <?php
    if (isset($_POST['archive']))
    {
            //on selectionne les infos sur notre choix
    	$MySQL_archive = mysql_query("SELECT * FROM $table ") or die(mysql_error());
    	$archive = mysql_fetch_assoc($MySQL_archive);
     
            //on affiche la question, les propositions et le nombre de votes
    	echo $archive['question']  . $infos['question']. "<br/>";
    	echo $archive['proposition1']  . $infos['proposition1'].'<br/>'. "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
    	echo $archive['proposition2'] . $infos['proposition2'].'<br/>'. "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
     
    	echo $archive['proposition3']  . $infos['proposition3'].'<br/>'. "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />.' . round($pourcentage_r3) . "% </label><br />";
     
            //on fait les tests habituels pour verifier la présences d'autres propositions
    	 if ($archive['proposition4'] != "")
    	 		echo $archive['proposition4'] . $infos['proposition4'].'<br/>'. "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
    	 	if ($archive['proposition5'] != "")
    	 		echo $archive['proposition5']  . $infos['proposition5'].'<br/>'. "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    	 }
     
     
    ?>
    merci d'avance

  15. #55
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Ajoute ta condition :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $MySQL_archive = mysql_query( "SELECT * FROM " . $table . " WHERE id = " . intval($_POST['archive']));
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    le formulaire m'affiche que le premier sondage.
    les resultats m'affiche le dernier sondage
    ==> je ne sais pas pk et quoi modifié?

    voici le script modifié:
    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
     
    <!-- formulaire -->
    <form method="post" action="archive.php">
    <p>
    Sondages archivés :
    <select name="archive">
            <?php
            require('configuration.php');
            //on crée une liste déroulante avec les questions des sondages effectués
    	$reponseMySQL = mysql_query("SELECT id, question FROM $table ") or die(mysql_error());
            while ($infos = mysql_fetch_assoc($reponseMySQL))
    	{
            echo "<option value=\"" . $numeroDuSondage['nbre_entrees'] . "\">" . $infos['question'] . "</option>";
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive"/>
    </p>
    </form>
    <!-- formulaire -->
     
    //resultat des sondages
    <?php
    if (isset($_POST['archive']))
    {
            //on selectionne les infos sur notre choix
    	$MySQL_archive = mysql_query( "SELECT * FROM " . $table . " WHERE id = " . intval($_POST['archive']));
    	$archive = mysql_fetch_assoc($MySQL_archive);
     
            //on affiche la question, les propositions et le nombre de votes
    	echo $archive['question']  . $infos['question']. "<br/>";
    	echo $archive['proposition1']  . $infos['proposition1'].'<br/>'. "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />.' . round($pourcentage_r1) . "% </label><br />";
    	echo $archive['proposition2'] . $infos['proposition2'].'<br/>'. "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />.' . round($pourcentage_r2) . "% </label><br />";
    	echo $archive['proposition3']  . $infos['proposition3'].'<br/>'. "<input type='radio' name='sondage' value='prop3' id='prop3' /> <label for='prop3'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />.' . round($pourcentage_r3) . "% </label><br />";
     
            //on fait les tests habituels pour verifier la présences d'autres propositions
    	 if ($archive['proposition4'] != "")
    	 		echo $archive['proposition4'] . $infos['proposition4'].'<br/>'. "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />.' . round($pourcentage_r4) . "% </label><br />";
    	 	if ($archive['proposition5'] != "")
    	 		echo $archive['proposition5']  . $infos['proposition5'].'<br/>'. "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" .'<img src="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    	 }
    ?>
    merci de votre aide

  17. #57
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Tu as un $info qui s'est transformé en $numeroDuSondage entre les deux codes.

    Soit plus vigilant sur les variables que tu utilises.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    exactement, merci de l'info.
    mais le problème, dans la liste déroulante du formulaire il affiche le premier résultat de la table mysql et j'aimerais qui affiche la question dans la liste déroulante:

    voici le code:
    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
     
    <form method="post" action="archive.php">
    <p>
    Sondages archivés :
    <select name="archive">
            <?php
     
            require('configuration.php');
            //on crée une liste déroulante avec les questions des sondages effectués
    	$reponseMySQL = mysql_query("SELECT id, question FROM $table ") or die(mysql_error());
            while ($infos = mysql_fetch_assoc($reponseMySQL))
    	{
            echo "<option value=\"" . $infos['id'] . "\">" . $infos['question'] . "</option>";
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive"/>
    </p>
    </form>
    je souhaiterais qui affiche la question dans la liste deroulante du résultat demandé

  19. #59
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Je n'ai rien compris :
    dans la liste déroulante du formulaire il affiche le premier résultat de la table mysql
    Qu'appelles-tu "le premier resultat de la table" ?
    Ta liste déroulante actuelle doit afficher toutes les champs "question" contenues dans la table.
    Ce n'est pas le cas ?

    je souhaiterais qui affiche la question dans la liste deroulante du résultat demandé
    c'est quoi "le résultat demandé" ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 284
    Points : 62
    Points
    62
    Par défaut
    dans la liste deroulante, je vois toute les question stocké dans la table sondage.
    quand je clique sur submit le résultat est bien celui demandé mais dans la liste deroulante ca affiche la premiere question stocké dans la base.

    ce que je souhaite c'est de voir dans la liste déroulante la question du résultat.

Discussions similaires

  1. Mise en place de sondage PHP
    Par ellolerron dans le forum PHP & Base de données
    Réponses: 11
    Dernier message: 07/03/2015, 23h18
  2. sondage php, probleme actualisation
    Par samspitz dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 21
    Dernier message: 04/12/2008, 11h58
  3. Sondage site de jeu Php
    Par webinfo dans le forum Général Conception Web
    Réponses: 0
    Dernier message: 11/10/2008, 15h31
  4. Sondage : Fonctionnalités attendues
    Par satchmo dans le forum W4 Express
    Réponses: 30
    Dernier message: 19/09/2007, 11h02

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