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 :

choix entre deux pages php a afficher


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 choix entre deux pages php a afficher
    bonjour,
    j'ai une page A (le sondage) dans un menu du site avec un liens vers les resultats page B et je souhaite quand la page B est cliqué que la page B prend la place de la page A, mais comment faire?

    comment afficher une autre page sur la meme page:

    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
    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
    138
    139
    140
    141
    142
    143
    144
    page A
    require('configuration.php');
    if (isset($_GET["sondage"])) $sondage=$_GET["sondage"];
    else $sondage="home";
    // vérification de la rubrique sélection afin d'être sûr qu'elle existe
    // on définit ci-dessous les pages correspondant à la rubrique
    //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 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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    // On recupere les nombre total de votes resultat
    $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;
    //recupere ip et on insere par rapport à l'id
    if(isset($_POST['sondage'])){
        $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());
       header('location:/');
    }
    
    
    $query = "SELECT vote_ip FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "'  " ;
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    
    
    
    ?>
    <br />
    <!-- formulaire-->
    <form method="post" name="sondage" >
    <?php
    //sondage aprés validation sans bouton
    if ($num > 0) {
    echo '<img src="img/_sondage.gif"><br>';
    if ($infos['question'] != "")
    echo '<span style="color:#4A1A2C;font-size:20px;font-weight:bold;">'.$infos['question'].'</span>'.'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo  ''.$infos['proposition1'].'</span>'.'<br/>'.  '<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "%<br />";
     
    	if ($infos['proposition2'] != "")
    echo  ''.$infos['proposition2'].'</span>'.'<br/>'.  '<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% <br />";
     
    if ($infos['proposition3'] != "")
    echo  ''.$infos['proposition3'].'</span>'.'<br/>'. '<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% <br />";
     
     
    	if ($infos['proposition4'] != "")
    echo  ''.$infos['proposition4'].'</span>'.'<br/>'. '<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% <br />";
     
         if ($infos['proposition5'] != "")
    echo  ''.$infos['proposition5'].'</span>'.'<br/>'. '<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% <br />";
     
    echo '<div align="right" class="archives"><a href="sondage.php?sondage=archive">les résultats des anciens sondages +</a></div><br><br><br>';
    
    //exit();// ce bouton casse le design du site
    
     }
     else {
    
     //sondage avec bouton avant validation
    echo '<img src="img/_sondage.gif"><br>';
     
    echo '<span style="color:#4A1A2C;font-size:15px;">'.$infos['question'].'</span>'.'<br/>'. "";
    echo  '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "% </label><br />";
     
    echo  '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% </label><br />";
     
           if ($infos['proposition3'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% </label><br />";
           if ($infos['proposition4'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% </label><br />";
     
    	   if ($infos['proposition5'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% </label><br /><br /><br />";
    
    echo '<input type="submit" name="voter" value="Voter !"/><br />';
    echo '<div align="right" class="archives"><a href="sondage/sondage.php?sondage=archive">les résultats des anciens sondages +</a></div>';
    
    }
    ?>
    //pour donner le choix au visiteur
    if (isset($_POST['sondage'])) {
    	if //je c pas comment faire
    	
    else {
    	header('location:/');
    merci de bien vouloir m'aider

  2. #2
    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
    Bonjour Samspitz,

    Un lien ne suffit pas ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="B.php" title="Accéder à la page B">B</a>

  3. #3
    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 souhaite:
    le visiteur quand il clique voir les resultats du sondage que cette page remplace le formulaire de vote .

    soit page A devient page B
    que page B devient Page A avec un retour

  4. #4
    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
    Samspitz,

    ce que tu dis est difficilement compréhensible, qu'entend-tu par "page A remplace page B" ?

    Quoique tu fasses la page A reste la page A et la B reste la B.

    Lorsque tu te trouves sur la page A tu peux faire un lien vers la page B comme je te l'ai indiqué ci-dessus, cela aura pour effet de rediriger l'internaute et donc d'afficher la page B lorsque celui ci aura cliqué dessus.

  5. #5
    Membre confirmé
    Développeur Web
    Inscrit en
    Avril 2005
    Messages
    397
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Avril 2005
    Messages : 397
    Points : 518
    Points
    518
    Par défaut
    Salut,

    Si je comprends bien tu veux simplement que :

    une fois le sondage remplie et validé, le formulaire du sondage ne soit plus apparent et à sa place on y retrouve le résultat

    ?
    Zend PHP5 Certification
    MySQL 4 Core Certification

  6. #6
    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
    oui c'est ca en cliquant sur le lien.
    comment je peux faire ca, car la suis perdu?

    le code du 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
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
     
    <?php
    //changement de page
    if (isset($_GET["sondage"])) $sondage=$_GET["sondage"];
    else $sondage="index.php";
     
    $sondage=0; 
    $pages=array();
     
    $pages[0]="archive";
    $pages=array();
    $pages[0]="sondage/archive.php";
     
    for ($i=0; $i<count($pages);$i++) {
    	if ($sondage==$pages[$i]) $sondage=$i;
    }//la perdu
     
     
    // récupération des rubriques
    require('configuration.php');
    if (isset($_GET["sondage"])) $sondage=$_GET["sondage"];
    else $sondage="home";
    // vérification de la rubrique sélection afin d'être sûr qu'elle existe
    // on définit ci-dessous les pages correspondant à la rubrique
    //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 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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    // On recupere les nombre total de votes resultat
    $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;
    //recupere ip et on insere par rapport à l'id
    if(isset($_POST['sondage'])){
        $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());
       header('location:/');
    }
     
     
    $query = "SELECT vote_ip FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "'  " ;
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
     
     
     
    ?>
    <br />
    <!-- formulaire-->
    <form method="post" name="sondage" >
    <?php
    //sondage aprés validation sans bouton
    if ($num > 0) {
    echo '<img src="img/_sondage.gif"><br>';
    if ($infos['question'] != "")
    echo '<span style="color:#4A1A2C;font-size:20px;font-weight:bold;">'.$infos['question'].'</span>'.'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo  ''.$infos['proposition1'].'</span>'.'<br/>'.  '<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "%<br />";
     
    	if ($infos['proposition2'] != "")
    echo  ''.$infos['proposition2'].'</span>'.'<br/>'.  '<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% <br />";
     
    if ($infos['proposition3'] != "")
    echo  ''.$infos['proposition3'].'</span>'.'<br/>'. '<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% <br />";
     
     
    	if ($infos['proposition4'] != "")
    echo  ''.$infos['proposition4'].'</span>'.'<br/>'. '<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% <br />";
     
         if ($infos['proposition5'] != "")
    echo  ''.$infos['proposition5'].'</span>'.'<br/>'. '<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% <br />";
     
    echo '<div align="right" class="archives"><a href="sondage/sondage.php?sondage=archive">les résultats des anciens sondages +</a></div><br><br><br>';
     
    //exit();// ce bouton casse le design du site
     
     }
     else {
     
     //sondage avec bouton avant validation
    echo '<img src="img/_sondage.gif"><br>';
     
    echo '<span style="color:#4A1A2C;font-size:15px;">'.$infos['question'].'</span>'.'<br/>'. "";
    echo  '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "% </label><br />";
     
    echo  '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% </label><br />";
     
           if ($infos['proposition3'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% </label><br />";
           if ($infos['proposition4'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% </label><br />";
     
    	   if ($infos['proposition5'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% </label><br /><br /><br />";
     
    echo '<input type="submit" name="voter" value="Voter !"/><br />';
    echo '<div align="right" class="archives"><a href="sondage/sondage.php?sondage=archive">les résultats des anciens sondages +</a></div>';
     
    }
    ?>
    merci

  7. #7
    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
    Et en changeant par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    header('location:'.$_SERVER['PHP_SELF']);
    Es-tu redirigé vers le résultat du sondage ?


    oui c'est ca en cliquant sur le lien.
    Il faut écrire le lien de la meme manière que je l'ai écris plus haut et le faire pointer vers la page qui contient les résultats.

  8. #8
    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 j'aimerais c'est connaitre, comprendre le script a ecrire pour pouvoir afficher la page B à la place de la page A en cliquant sur le lien....

    si yavais une gentil personne qui pourrais me guidé en commentant le code....

    merci

  9. #9
    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
    Samspitz,

    je cherche à t'aider, tu ne réponds pas à mes questions ni ne lis mes réponses j'ai l'impression.

    À priori, et aux vues des informations que tu donne, il n'y a pas de "script" à écrire, tu mets juste un lien vers la page que tu souhaites afficher et voilà...

    Pourrais-tu expliquer concrètement ce que tu souhaites faire ? Merci de ne pas répondre "remplacer page A par page B" mais à la limite décrire le comportement attendu par tes pages de manière carthésienne.

  10. #10
    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
    désolé d'être incomprehensible.
    j'ai un systéme de votage stocké sur mon index.php(sondage.php), ce systeme à un lien pointant vers archive.php.
    ce que je souhaite, dés que le visiteur clique sur ce lien, cette page s'affiche à la place du systeme de sondage. donc remplacer sondage.php par archive.php sur mon index.php.
    j'imagine à un choix de redirection dés le debut du script mais ne sachant pas le faire. un if j'imagine

    merci de votre patience

  11. #11
    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
    La page index.php doit pouvoir savoir si on souhaite afficher le sondage ou la page des archives :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    if(isset($_GET['page'])){
        $page_file = $_GET['page'].'php';
        if(is_file($page_file)){
            include($page_file);
        }
        else{
            header('location:/');
        }
    }
    Ensuite il te suffit de faire un lien comme ceci si tu veux les sondages :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <a href="index.php?page=sondage">Sondage</a>
    Si tu veux un sondage spécifique tu peux très bien faire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <a href="index.php?page=sondage&id=2">Sondage</a>
    et manipuler $_GET['id'] dans la page sondage.php

    et comme ceci pour les archives

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <a href="index.php?page=archives">Archives</a>

    J'éspère avoir pu t'aider et avoir été relativement clair.

  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
    j'ai un include de la page sondage.php sur index.php et j'aimerais géré tout par cette page. quel seront les modification?

    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
    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
    138
    139
    140
    141
    142
    143
     
    <?php
    if(isset($_GET['page'])){
        $page_file = $_GET['archive'].'php';
        if(is_file($page_file)){
            include($page_file);
        }
        else{
            header('location:'.$_SERVER['PHP_SELF']);
     
        }
    }
     
     
     
     
    // récupération des rubriques
    require('configuration.php');
    $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 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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    // On recupere les nombre total de votes resultat
    $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;
    //recupere ip et on insere par rapport à l'id
    if(isset($_POST['sondage'])){
        $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());
      header('location:'.$_SERVER['PHP_SELF']);
     
    }
     
     
    $query = "SELECT vote_ip FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "'  " ;
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
     
     
     
    ?>
    <br />
    <!-- formulaire-->
    <form method="post" name="sondage" >
    <?php
    //sondage aprés validation sans bouton
    if ($num > 0) {
    echo '<img src="img/_sondage.gif"><br>';
    if ($infos['question'] != "")
    echo '<span style="color:#4A1A2C;font-size:20px;font-weight:bold;">'.$infos['question'].'</span>'.'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo  ''.$infos['proposition1'].'</span>'.'<br/>'.  '<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "%<br />";
     
    	if ($infos['proposition2'] != "")
    echo  ''.$infos['proposition2'].'</span>'.'<br/>'.  '<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% <br />";
     
    if ($infos['proposition3'] != "")
    echo  ''.$infos['proposition3'].'</span>'.'<br/>'. '<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% <br />";
     
     
    	if ($infos['proposition4'] != "")
    echo  ''.$infos['proposition4'].'</span>'.'<br/>'. '<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% <br />";
     
         if ($infos['proposition5'] != "")
    echo  ''.$infos['proposition5'].'</span>'.'<br/>'. '<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% <br />";
     
    echo '<div align="right" class="archives"><a href="index.php?page=archives">les résultats des anciens sondages +</a></div><br><br><br>';
     
    //exit();// ce bouton casse le design du site
     
     }
     else {
     
     //sondage avec bouton avant validation
    echo '<img src="img/_sondage.gif"><br>';
     
    echo '<span style="color:#4A1A2C;font-size:15px;">'.$infos['question'].'</span>'.'<br/>'. "";
    echo  '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "% </label><br />";
     
    echo  '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% </label><br />";
     
           if ($infos['proposition3'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% </label><br />";
           if ($infos['proposition4'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% </label><br />";
     
    	   if ($infos['proposition5'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% </label><br /><br /><br />";
     
    echo '<input type="submit" name="voter" value="Voter !"/><br />';
    echo '<div align="right" class="archives"><a href="index.php?page=archives">les résultats des anciens sondages +</a></div>';
     
    }
    ?>
    merci enormement

    le sondage reste en place, toujours la redirection qui est pris en compte. pk?
    de l'aide svp

  13. #13
    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 php affichage multiple
    bonsoir,

    J'ai un script sondage qui permet de voté, aprés avoir voté les visiteurs peuvent aller visité les archives de tous les sondages grace a un liens. Quand ces visiteurs clique sur ce lien je souhaite que cette page remplace sur la même page la partie sondage. Mon probléme est que je n'arrive pas à remplacer cette partie, à chaque fois ça ouvre une nouvelle page.

    le script:
    si partie sondage alors on affiche la partie 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
    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
     
    <?php
    //recupereration page a afficher
    if(isset($_GET['sondage'])){
        $page = $_GET['sondage'];}
        if(!$_GET['sondage'] == 'archive') {
     
    //partie vote
     
    require('configuration.php');
    $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 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 = '" . $numeroDuSondage['nbre_entrees'] . "'") or die(mysql_error());
    			$fin = true;
    		}
    	}
    }
    // On recupere les nombre total de votes resultat
    $query = "SELECT * from 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;
    //recupere ip et on insere par rapport à l'id
    if(isset($_POST['sondage'])){
        $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());
     
     
    }
    $query = "SELECT vote_ip FROM $table1 WHERE sondage_id="."'" . $numeroDuSondage['nbre_entrees'] . "'  " ;
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    ?>
    <br />
    <form method="post" name="sondage" >
    <?php
    //sondage aprés validation sans bouton
    if ($num > 0) {
    echo '<img src="img/_sondage.gif"><br>';
    if ($infos['question'] != "")
    echo '<span style="color:#4A1A2C;font-size:20px;font-weight:bold;">'.$infos['question'].'</span>'.'<br/>'. "";
    if ($infos['proposition1'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'.  '<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "%<br />";
     
    	if ($infos['proposition2'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  '<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% <br />";
     
    if ($infos['proposition3'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'. '<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% <br />";
     
     
    	if ($infos['proposition4'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'. '<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% <br />";
     
         if ($infos['proposition5'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'. '<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% <br />";
     
    echo '<div align="right" class="archives"><a href="index.php?rub=sondage">les résultats des anciens sondages +</a></div><br>';
    }
     else {
    //sondage avec bouton avant validation
    echo '<img src="img/_sondage.gif"><br>';
     
    echo '<span style="color:#4A1A2C;font-size:15px;">'.$infos['question'].'</span>'.'<br/>'. "";
    echo  '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "% </label><br />";
     
    echo  '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop2' id='prop2' /> <label for='prop2'>" .'<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% </label><br />";
     
           if ($infos['proposition3'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop3' /> <label for='prop3'>" .'<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% </label><br />";
           if ($infos['proposition4'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop4' /> <label for='prop4'>" .'<img src="img/sondage/bluerond.gif">'.'<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% </label><br />";
     
    	   if ($infos['proposition5'] != "")
    echo  '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'.  "<input type='radio' name='sondage' value='prop' id='prop5' /> <label for='prop5'>" .'<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% </label><br />";
     
     
    echo '<input type="submit" name="voter" value="Voter !"/><br />';
    echo '<div align="right" class="archives"><a href="index.php?rub=archive">les résultats des anciens sondages +</a></div>';
    }
    }
    sinon partie archive:
    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
     
    else{//ici, le deuxieme affichage { la partie archive.php}
     
    if( isset($_POST['archive']) ){
    $nbr=$_POST['archive'];}
    echo '<img src="img/_sondage.gif"><br>';
    ?>
    <form method="post">
    <p>
    Sondages archivés :
    <select name="archive">
    <?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'] .'"';
    		        if(isset($_POST['archive']) && $_POST['archive'] == $infos['id']) echo ' selected="selected"';
    		        echo '>'.$infos['question'].'</option>';
    	}
    	?>
    </select><br/>
    <input type="submit" value="Voir l'archive "/><br/><br/>
     
    <?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 " . $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'] . '<span style="color:#4C1B1B;font-size:20px;">'.$infos['question'].'</span>'.'<br/>'. "";
    	echo $archive['proposition1']  . '<span style="padding-left:2em;">'.$infos['proposition1'].'</span>'.'<br/>'. '<img src="img/sondage/greenrond.gif">'.'<img src="img/sondage/green.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/greendroit.gif"/>' . round($pourcentage_r1) . "% </label><br />";
    	echo $archive['proposition2'] . '<span style="padding-left:2em;">'.$infos['proposition2'].'</span>'.'<br/>'.  '<img src="img/sondage/blackrond.gif">'.'<img src="img/sondage/black.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/blackdroit.gif"/>' . round($pourcentage_r2) . "% </label><br />";
    	if ($archive['proposition3'] != "")
    		echo $archive['proposition3']  . '<span style="padding-left:2em;">'.$infos['proposition3'].'</span>'.'<br/>'.  '<img src="img/sondage/redrond.gif">'.'<img src="img/sondage/red.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/reddroit.gif"/>' . round($pourcentage_r3) . "% </label><br />";
     
     
    	 if ($archive['proposition4'] != "")
    	 		echo $archive['proposition4'] .'<span style="padding-left:2em;">'.$infos['proposition4'].'</span>'.'<br/>'. '<img src="img/sondage/blue.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/bluedroit.gif"/>' . round($pourcentage_r4) . "% </label><br />";
    	 	if ($archive['proposition5'] != "")
    	 		echo $archive['proposition5']  . '<span style="padding-left:2em;">'.$infos['proposition5'].'</span>'.'<br/>'.'<img src="img/sondage/copperrond.gif">'.'<img src="img/sondage/copper.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/copperdroit.gif"/>' . round($pourcentage_r5) . "% </label><br /><br /><br />";
    	 }
    }
    ?>
    merci d'avance de votre aide

  14. #14
    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 suis arrivé à mon probléme, merci de m'avoir lu et aidé

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Choix entre deux pages
    Par yasseross dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 22/01/2013, 15h07
  2. [PHP 5.3] relation entre deux page: Connexion.php et une autre
    Par sulfuryblood dans le forum Langage
    Réponses: 3
    Dernier message: 11/02/2011, 12h44
  3. passage de parametre entre deux page asp
    Par tomtom25 dans le forum ASP
    Réponses: 4
    Dernier message: 01/04/2005, 16h16

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