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. #1
    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 fonctionnalité sondage php
    hi all,

    Je cherche à développez un sondage par langue soit poiur chaque site il detecte la langue.?
    Je cherche aussi à pouvoir qu'un seul visiteur puisse voter?

    pourriez-vous m'eclaircir sur ces points ou m'envoyer vers des tutoriels qui parle de ces sujets

    merci d'avance,

  2. #2
    Membre du Club
    Profil pro
    Développeur Web
    Inscrit en
    Avril 2008
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2008
    Messages : 49
    Points : 51
    Points
    51
    Par défaut
    salut,

    pour ton problème de langue regarde autour de la variable $_SERVER['HTTP_ACCEPT_LANGUAGE']

    Pour le nombre de clique par utilisateur, tu dois utiliser les variables de session.

    Donc passer par $_SESSION

    Je te laisse chercher sur google comment tout fonctionne, c'est largement documenté.

  3. #3
    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
    Une session n'est pas suffisante pour identifier un utilisateur puisqu'elle disparait a la fermeture du navigateur.

    L'ip reçu par le serveur web n'est pas nécessairement individualisée.

    Le cookie peut etre supprimé.

    Même avec une authentification, un utilisateur pourrait s'inscrire deux fois.

    Il n'y pas de méthode evidente pour isoler un vote.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  4. #4
    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
    ce que je cherche:
    - une base mysql permettant de choisir la langue pour la version langue du site.
    - de detecter la langue à l'entrée du visiteur pour choisir le sondage à afficher

    - d'empecher le multivotage d'un visiteur

    aprés une recherche infructueuse, j'aimerais obtenir une grande aide de votre part

    merci d'avance,

  5. #5
    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
    re-bonjour.

    j'ai plusieurs probleme
    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
     <!-- formulaire -->
    <form method="post">
       <?php echo "" . $infos['question'] . ""; ?> <br />
    	<?php echo $infos['proposition1']; ?><br />
    		<input type="radio" name="sondage" value="prop1" id="prop1" /><label for="prop1"> <?php echo ('<img src="black.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r1).'%" />') ?> <?php echo round($pourcentage_r1) . "  %"; ?> </label><br />
    	<?php echo $infos['proposition2']; ?><br />
    		<input type="radio" name="sondage" value="prop2" id="prop2" /> <label for="prop2"> <?php echo ('<img src="blue.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />') ?> <?php echo round($pourcentage_r2) . "  %"; ?></label><br />
    	<?php echo $infos['proposition3']; ?><br />
    		<input type="radio" name="sondage" value="prop3" id="prop3" /> <label for="prop3"> <?php echo ('<img src="copper.jpg" height="10"width="' . $pourcentage_r3 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r3).'%" />') ?> <?php echo round($pourcentage_r3) . "  %"; ?></label><br />
    //////////////////////////////////////////////////////////////////////////////////
    // j'aimerais obtenir le meme resultat qu'en php que le script du dessus en phph-html//////////////////////////////////////////////////////////////////////
    ///////////	
    <?php
    	if ($infos['proposition4'] != "")
    		       echo "<input type='radio' name='sondage' value='prop4' id='prop4' /> <label for='prop4'>" . $infos['proposition4'] . " ..... (votes : " . $votes['resultats4'] . ") </label><br />";
     
    		if ($infos['proposition5'] != "")
    		       echo "<input type='radio' name='sondage' value='prop5' id='prop5' /> <label for='prop5'>" . $infos['proposition5'] . " ..... (votes : " . $votes['resultats5'] . ") </label><br />";
    		?>

    j'aimerais obtenir le meme resultat qu'en php que le script du dessus en phph-html, help me ( plein d'essais ans reussite)

    merci d'avance

  6. #6
    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
    une base mysql permettant de choisir la langue pour la version langue du site.
    Quelle difficulté rencontres-tu sur ce point ?
    As-tu déjà créé la structure de la table ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  7. #7
    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 de la réponse

    juste avant j'ai un probleme de traduction tout en language php, si vous pouvez m'aider

    mon code est triée à chaque fois par le plus grand 'id' donc cmt choisir par la langue

    merci

  8. #8
    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 pas compris ta question sur les ids.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  9. #9
    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
    en clair, je ne sais pas du tout comment gerer les langues....

    mon autre question c que j'arrive pas a traduire en php le code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <?php echo "" . $infos['question'] . ""; ?> <br />
    	<?php echo $infos['proposition1']; ?><br />
    		<input type="radio" name="sondage" value="prop1" id="prop1" /><label for="prop1"> <?php echo ('<img src="black.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r1).'%" />') ?> <?php echo round($pourcentage_r1) . "  %"; ?> </label><br />
    merci

  10. #10
    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 y a déjà du php dans ce que tu ecris.

    Ca serait plus lisible si tu ecrivais plutot comme ca :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <?php echo "" . $infos['question'] . ""; ?> <br />
    <?php echo $infos['proposition1']; ?><br />
    ===>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <?php
    echo $infos['question'] .'<br />' . $infos['proposition1'] .'<br />';
    ?>
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  11. #11
    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
    Je récupére ip du visiteur, je l'insere dans la la base mysql et j'aimerais juste qu'il compte a chaque fois dans id et a chaque nouveau sondage(id) que ce visiteur puisse voter mais comment faire?

    voici la table mysql:
    Code sql : 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
    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

    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
    // On récupère le vote et l'ip du visiteur
    $ip = $_SERVER['REMOTE_ADDR'];
    $query = "SELECT * FROM ".$table." WHERE 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="copper.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="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    exit;
    }
    //note importante : s'insere toujours dans un nouveau id//
    $sql = "INSERT INTO $table (ip) VALUES ('$ip') WHERE id="."'" . $numeroDuSondage['nbre_entrees'] . "'";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    merci d'avance de votre aide

  12. #12
    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 sondage par langue en php
    bonjour à tous,

    Voici mon probléme, je souhaiterais grace a une base mysql d'afficher le sondage dans la langue du visiteur: MAIS COMMENT FAIRE:

    voici la base mysql:
    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
    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
    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
     
    <?php
    require('configuration.php');
    // Détection de la langue :
    if (!isset( $_POST['lang'])) {
    	$langs=explode(",",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
    	if ($langs[0]!="fr") $lang="en";
    	else $lang="fr";
    }
    else $lang=$_GET['lang'];
     
    // pour éviter des erreurs, on force la langue en français
    $lang="fr";
     
    //On prend l'id le plus grand
    $nombreEntrees = mysql_query("SELECT MAX(id) AS nbre_entrees FROM sondage") or die(mysql_error());
    $numeroDuSondage = mysql_fetch_assoc($nombreEntrees);
    //On sélectionne la question et les choix
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage WHERE id = '" . $numeroDuSondage['nbre_entrees'] . "'";
    $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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    $votes = mysql_fetch_assoc($MySQL_votes);
    //script pour ajouter les votes
     
    //script pour ajouter les votes
    $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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    ?>
    <?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
     
     
    // On récupère le vote et l'ip du visiteur
    $ip = $_SERVER['REMOTE_ADDR'];
    $query = "SELECT ip FROM ".$table." WHERE 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="copper.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="copper.jpg" height="10"width="' . $pourcentage_r5 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r5).'%" />.' . round($pourcentage_r5) . "% </label><br />";
    exit;
    }
    //note importante : s'insere toujours dans un nouveau id//
    $sql = "INSERT INTO $table (ip) VALUES ('$ip') WHERE id="."'" . $numeroDuSondage['nbre_entrees'] . "'";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    ?>
     
    <!-- formulaire -->
    <form method="post">
       <?php echo "" . $infos['question'] . ""; ?> <br />
    	<?php echo $infos['proposition1']; ?><br />
    		<input type="radio" name="sondage" value="prop1" id="prop1" /><label for="prop1"> <?php echo ('<img src="black.jpg" height="10"width="' . $pourcentage_r1 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r1).'%" />') ?> <?php echo round($pourcentage_r1) . "  %"; ?> </label><br />
    	<?php echo $infos['proposition2']; ?><br />
    		<input type="radio" name="sondage" value="prop2" id="prop2" /> <label for="prop2"> <?php echo ('<img src="blue.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />') ?> <?php echo round($pourcentage_r2) . "  %"; ?></label><br />
    	<?php echo $infos['proposition2']; ?><br />
    		<input type="radio" name="sondage" value="prop2" id="prop2" /> <label for="prop2"> <?php echo ('<img src="blue.jpg" height="10"width="' . $pourcentage_r2 / 100 * $long_max_bloc . '"
            alt="'.round($pourcentage_r2).'%" />') ?> <?php echo round($pourcentage_r2) . "  %"; ?></label><br />
         <?php
           if ($infos['proposition4'] != "")
    	   			       echo $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 ($infos['proposition5'] != "")
    	   	 			       echo $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 />";
    ?>
    <input type="submit" value="Voter !"/>
    </form>
    qqn pourrait-il m'eclaircir svp?
    merci

  13. #13
    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 colonne IP ne peut pas être dans la table sondage.
    Il te faut une table qui enregistre sondage_id, IP pour chaque votant.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  14. #14
    Invité
    Invité(e)
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?php
    // ...
    // pour éviter des erreurs, on force la langue en français
    $lang="fr";
    // Détection de la langue :
    if (!isset( $_POST['lang'])) {
    	$langs=explode(",",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
    	if ($langs[0]!="fr") $lang="en";
    	else $lang="fr";
    }
    else $lang=$_GET['lang'];
    } 
    // ...
    ?>

  15. #15
    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 de la réponse.
    comment je peux faire ça? ( je vois pas trop la......)

  16. #16
    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 de la réponse,

    comment peut-on reconnaitre et afficher la langue du visiteur?

  17. #17
    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 deux problemes donc j'aimerais bien beneficier de votre aide.

    le premier est afficher le sondage par langue du visiteur.
    voici la table mysql:
    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
     
    DROP TABLE IF EXISTS sondage;
    CREATE TABLE `sondage` (
    `id` SMALLINT NOT NULL AUTO_INCREMENT,
    ip char(50),
    lang varchar(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
    le script pour inserer la langue du sondage:
    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 (lang) VALUES ('$lang') ";
    mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
    le script pour detecter la langue et afficher le sondage par langue:
    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
     
    <?php
    require('configuration.php');
    // Détection de la langue :
    // pour éviter des erreurs, on force la langue en français
    $lang="fr";
    // Détection de la langue :
    if (!isset( $_POST['lang'])) {
    	$langs=explode(",",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
    	if ($langs[0]!="fr") $lang="en";
    	else $lang="fr";
    }
    else $lang=$_POST['lang'];
    //On prend l'id le plus grand
    $nombreEntrees = mysql_query("SELECT MAX(id) AS nbre_entrees FROM sondage") or die(mysql_error());
    $numeroDuSondage = mysql_fetch_assoc($nombreEntrees);
    //On sélectionne la question et les choix
    $req="SELECT question, proposition1, proposition2, proposition3, proposition4, proposition5 FROM sondage WHERE id = '" . $numeroDuSondage['nbre_entrees'] . "' and lang='$lang'";
    $MySQL_infos = mysql_query($req) or die(mysql_error());
    $infos = mysql_fetch_array($MySQL_infos);
    merci de bien vouloir m'aidé de m'eclaircir sur ces sujets

  18. #18
    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
    Qu'est ce qui ne fonctionne pas dans le script que tu nous montres ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  19. #19
    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 plus de precision, je dois ajouter insertion ip afin de verifié si lez visiteur à deja voté.

    voila le script insertion:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    $votes[$resultat . $i] ++;
    mysql_query("UPDATE sondage SET "  . $resultat . $i ." = '" . $votes[$resultat . $i] . "' WHERE id = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    $fin = true;
    comment faire, quel ligne a ajouter?
    help me please

  20. #20
    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 t'ai déjà répondu :
    Ta colonne IP ne peut pas être dans la table sondage puisque tu as plusieurs IP pour un seul sondage.
    Il te faut une table qui enregistre sondage_id, IP pour chaque votant.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

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