Salut à tous,
J'aimerais beneficier de votre aide afin de finalisé mon script et aboutir à :
- affichage des questions dans le formulaire stocké dans mysql
- la boucle du compteur des votes
- les images se resize selon les votes
voici le script:
merci de votre aide!
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 <?php // connexion a la bdd require("configuration.php"); mysql_connect($hote,$login,$mot_passe); mysql_select_db($nom_base); //On prend l'id le plus grand (donc le plus récent). $nombreEntrees = mysql_query("SELECT MAX(id) AS nbre_entrees FROM sondage") or die(mysql_error()); $numeroDuSondage = mysql_fetch_assoc($nombreEntrees); //On sélectionne le nombre de votes $MySQL_votes = mysql_query("SELECT resultats1, resultats2, resultats3 FROM sondage WHERE id = '" . $numeroDuSondage['id'] . "'") or die(mysql_error()); $votes = mysql_fetch_assoc($MySQL_votes); //On sélectionne la question et les choix $MySQL_infos = mysql_query("SELECT question, proposition1, proposition2, proposition3 FROM sondage WHERE id = '" . $numeroDuSondage['id'] . "'") or die(mysql_error()); $infos = mysql_fetch_array($MySQL_infos); $prop = "prop"; $resultat = "resultats"; $fin = false; if(isset($_POST['sondage'])) { for($i = 0; $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; } } } ?> <table width="400" border="0" cellspacing="0" cellpadding="2"> <form method='post' action='voter.php'> <tr> <td align="center"><?php echo $question; ?></td> </tr> <tr><td><?php echo rep[0]; ?></td></tr> <tr><td><input type="radio" name="sondage" value="prop1" id="prop1" /> <label for="prop1"><?php echo $infos['proposition1'] . "<img src='black.jpg'>" . $votes['resultats1'] . "round($pourcentage) "; ?> </label></td></tr> <tr><td><?php echo $rep[1]; ?></td></tr> <tr><td><input type="radio" name="sondage" value="prop2" id="prop2" /> <label for="prop2"><?php echo $infos['proposition2'] . "<img src='blue.jpg'>" . $votes['resultats2'] . ")"; ?></label></td></tr> <tr><td><?php echo $rep[2]; ?></td></tr> <tr><td><input type="radio" name="sondage" value="prop3" id="prop3" /> <label for="prop3"><?php echo $infos['proposition3'] . "<img src='copper.jpg'>" . $votes['resultats3'] . ")"; ?></label></td></tr> <tr><td align="center"><input type="submit" value="voter"></td> </form> </table>
Partager