Bonjour,
je réalise un site web dynamique et lors de la conception d'un sondage en php, j'ai rencontré un 'tit problème
mon code est le suivant :
j'ai bien crée mes tables mysql, tout marche sauf que j'ai ce message:
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
150
151
152
153
154
155 <?php $query = mysql_query("SELECT * FROM 'poll' ORDER BY 'id' DESC LIMIT 1"); $rows = mysql_num_rows($query); if($rows > 0){ $poll = mysql_fetch_array($query); $title = $poll['name']; } else { $title = 'No Poll Yet'; } $query = mysql_query("SELECT COUNT('id') as hits FROM 'responses' GROUP BY 'qid'"); while($row = mysql_fetch_array($query)){ $me[] = $row['hits']; } $max = max($me); $query = mysql_query("SELECT 'questions'.'pid' FROM 'responses', 'questions' WHERE 'responses'.'qid'='questions'.'id' AND 'responses'.'ip'='".$_SERVER['REMOTE_ADDR']."' AND pid='".$poll['id']."'"); if(mysql_num_rows($query) > 0){ $total = mysql_query("SELECT 'questions'.'pid' FROM 'responses', 'questions' WHERE 'responses'.'qid'='questions'.'id' AND pid='".$poll['id']."'"); $total = mysql_num_rows($total); ?> <style type="text/css"> <!-- .maintable { font-size: x-small; font-family: "Times New Roman", Times, serif; background-color: #F00; } .maintable tr .title { font-size: 12px; } .maintable tr td form .question tr td { font-size: 12px; } --> </style> <table width="127" border="0" align="center" cellpadding="0" cellspacing="0" class="maintable"> <tr> <td width="127" align="center" valign="top" class="title"><?php echo $title; ?></td> </tr> <?php $query = mysql_query("SELECT * FROM 'questions' WHERE 'pid'='".$poll['id']."' ORDER BY 'question'"); $questions = mysql_num_rows($query); if($questions > 0){ ?> <tr> <td valign="top" style="padding: 5px; font-size: 12px;"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="question"> <?php while($question = mysql_fetch_array($query)){ $responses = mysql_query("SELECT count(id) as total FROM 'responses' WHERE qid='".$question['id']."'"); $responses = mysql_fetch_array($responses); if($total > 0 && $responses['total'] > 0){ $percentage = round(($responses['total'] / $max) * 100); } else { $percentage = 0; } $percentage2 = 100 - $percentage; ?> <tr> <td valign="top" nowrap="nowrap"><?php echo $question['question']; ?></td> <td valign="top" height="10" width="100%" style="padding: 0px 10px; font-size: small; font-family: 'Times New Roman', Times, serif;"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top" width="<?php echo $percentage; ?>%" <?php if($percentage > 0){?>style="background: url('images/bar.jpg') repeat-x;"<?php } ?>><img src="images/dot.gif" width="1" height="19" /></td> <td valign="top" width="<?php echo $percentage2; ?>%"></td> </tr> </table> </td> <td valign="top"><?php echo $responses['total']; ?></td> </tr> <?php } ?> <tr> <td valign="top" colspan="3" align="center" style="padding: 10px 0px 0px 0px; font-size: 12px;">Total Votes: <?php echo $total; ?></td> </tr> </table> </td> </tr> <?php } ?> </table> <?php } else { ?> <table width="127" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center"> <tr> <td width="127" align="center" valign="top" class="title"><?php echo $title; ?></td> </tr> <?php $query = mysql_query("SELECT * FROM 'questions' WHERE 'pid'='".$poll['id']."' ORDER BY 'question'"); $questions = mysql_num_rows($query); if($questions > 0){ ?> <tr> <td valign="top" style="padding: 5px; font-size: 12px;"> <form name="poll" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="question"> <?php if(isset($error)){ ?> <tr> <td valign="top" colspan="2" align="center" style="padding: 0px 0px 10px 0px;"><?php echo $error; ?></td> </tr> <?php } ?> <?php while($question = mysql_fetch_array($query)){ ?> <tr> <td valign="top" style="padding: 0px 10px 0px 0px;"><input type="radio" name="questions" value="<?php echo $question['id']; ?>" /></td> <td valign="top" width="100%"><?php echo $question['question']; ?></td> </tr> <?php } ?> <tr> <td valign="top" colspan="2" align="center" style="padding: 10px 0px 0px 0px;"><input type="submit" name="vote" value="Submit Vote" /><br /></td> </tr> </table> </form> </td> </tr> <?php } ?> </table> <span class="maintable"></span> <?php } ?> <table width="127" cellpadding="0" cellspacing="0" border="0" align="center"> <tr> <td width="127" align="right" valign="top"> </td> </tr> </table>
Notice: Undefined variable: me in D:\EasyPHP5.3.0\www\poll.php on line 24
Warning: max() [function.max]: When only one parameter is given, it must be an array in D:\EasyPHP5.3.0\www\poll.php on line 24
merci de bien vouloir m'aider![]()
Partager