Bonjour,

J'ai un problème avec une requête SQL, qui lors de la soumission de celle-ci, ne mets pas à jours mes tableaux de données.

Ci-dessous mon script, pouvez-vous voir si ma requête sql (en gras) est correcte.

En vous remerciant d'avance,

Nico





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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<div style="text-align : left; width:750px;">
	
	<h2 style="text-align : center;">Records du club</h2>
	
	<br/>

	<form name="recherche" method="POST" action="index.php?page=record" style=" border : 1px solid silver; margin-left : 100px; width : 575px; height : 160px;text-align : center;background-image:url('img/loupe.jpg');background-repeat:no-repeat">
	
		<table style="width:300px;margin-left : 150px;">
			<tr>
				<td width="75px" style="font-weight : bold; text-decoration : underline;">Sexe : </td>
				<td><input width="100px" type="radio" name="sexe" value="2"/> Fille</td>
				<td><input width="100px" type="radio" name="sexe" value="1"/> Garcon</td>
			<tr>
		</table>
		
		<table style="width:300px;margin-left : 150px;">
			<tr>
				<td width="75px" style="font-weight : bold; text-decoration : underline;">Bassin : </td>
				<td><input width="100px" type="radio" name="bassin" value="25"/> 25 m</td>
				<td><input width="100px" type="radio" name="bassin" value="50"/> 50 m</td>
			<tr>
		</table>
		
		<table style="width:575px;">
			<tr>
				<td  style="font-weight : bold; text-decoration : underline;" colspan="4">Catégorie : </td>
			</tr>
			<tr>
				<td><input type="radio" name="categorie" value="caneton (annee 1)"/> Canetons (annee 1)</td>
				<td><input type="radio" name="categorie" value="caneton (annee 2)"/> Canetons (annee 2)</td>
				<td><input type="radio" name="categorie" value="caneton (annee 3)"/> Canetons (annee 3)</td>
				<td><input type="radio" name="categorie" value="benjamin (annee 1)"/> Benjamins  (annee 1)</td>
				<td><input type="radio" name="categorie" value="benjamin (annee 2)"/> Benjamins  (annee 2)</td>
				<td><input type="radio" name="categorie" value="minime (annee 1)"/> Minimes  (annee 1)</td>
				<td><input type="radio" name="categorie" value="minime (annee 2)"/> Minimes  (annee 2)</td>
			</tr>
			<tr>
				<td><input type="radio" name="categorie" value="cadet (annee 1)"/> Cadets  (annee 1)</td>
				<td><input type="radio" name="categorie" value="cadet (annee 2)"/> Cadets  (annee 2)</td>
				<td><input type="radio" name="categorie" value="junior (annee 1)"/> Juniors  (annee 1)</td>
				<td><input type="radio" name="categorie" value="junior (annee 2)"/> Juniors  (annee 2)</td>
				<td><input type="radio" name="categorie" value="senior"/> Seniors</td>
				<td><input type="radio" name="categorie" value="master"/> Masters</td>
				<td><input type="radio" name="categorie" value="open"/> Open</td>
			<tr>
		</table>

		<br/>
		<input type="submit"/>
	
	</form>
<br/>

	<?php
	
		$whereSexe = '';
		$whereCategorie = '';
		$whereBassin = '';
	
		$sexe = getVariable('sexe');

		if($sexe != ''){
			$whereSexe = " nageur.sexe = ".$sexe." ";
		}
		
		$categorie = getVariable('categorie');

		if($categorie != ''){
			$whereCategorie = ' A.categorie = "'.$categorie.'" ';
		}
		
		$bassin = getVariable('bassin');
		
		if($bassin != ''){
			$whereBassin = ' A.bassin = "'.$bassin.'m" ';
		}
		
		$where = ' ';
		if($categorie != '' && $categorie != 'open' && $sexe != '' && $bassin != ''){
			$where = " WHERE ".$whereSexe." AND ".$whereCategorie." AND ".$whereBassin." AND A.temps > 0 ";
		}
		else if($categorie != '' && $categorie != 'open' &&  $sexe != ''){
			$where = " WHERE ".$whereSexe." AND ".$whereCategorie." AND A.temps > 0 ";
		}
		else if($categorie != '' && $categorie != 'open' &&  $bassin != ''){
			$where = " WHERE ".$whereCategorie." AND ".$whereBassin." AND A.temps > 0 ";
		}
		else if($sexe != '' && $bassin != ''){
			$where = " WHERE ".$whereSexe." AND ".$whereBassin." AND A.temps > 0 ";
		}
		elseif($categorie != '' && $categorie != 'open' ){
			$where = " WHERE ".$whereCategorie." AND A.temps > 0 ";
		}
		elseif($sexe != ''){
			$where = " WHERE ".$whereSexe." AND A.temps > 0 ";
		}
		elseif($bassin != ''){
			$where = " WHERE ".$whereBassin." AND A.temps > 0 ";
		}
		
		if($where == ' '){
			$where = " WHERE A.temps > 0 ";
		}
		
		$filtreSexe = '';
		if($sexe == 1){
			$filtreSexe = 'Garcon';
		}
		elseif($sexe == 2){
			$filtreSexe = 'Fille';
		}
		
		echo '<h2>Filtre : '.strtoupper($categorie).' '.$filtreSexe.'</h2>';
	
		$o_connexionBDD = new connexionBDD();
		
		$o_nage = new nage();
		if($o_nage->getAll()){
		
			for($i=0; $i < $o_nage->i_nbLigne; $i++){
			
				$o_nage->nextLine();
				
				$requete = "select nageur.nom as nom, nageur.prenom as prenom, 	A.id as id, A.idNageur as idNageur, A.categorie as categorie, A.idCompetition as idCompetition, 
							A.idNage as idNage, A.temps as temps, A.place as place, A.bassin as bassin
							from  resultat as A 
								INNER JOIN nageur ON A.idNageur = nageur.id
							".$where." AND A.idNage = '".$o_nage->id."' AND A.place >= 0
							ORDER BY idNage ASC, temps ASC
							LIMIT 0, 1";
					
				$sql = mysql_query($requete);
		

				if($sql){			
					
					if(mysql_num_rows($sql) > 0){
					
						$ligne = mysql_fetch_assoc($sql);
						
						if($ligne){
						
							$nomCompetition = '';
							$dateCompetition = '';
							$piscine = '';
							$lieu = '';
							$o_competition = new competition();
							$o_competition->id = $ligne['idCompetition'];
							if($o_competition->getByID()){
								$nomCompetition = $o_competition->nom;
								$dateCompetition = date('d/m/Y',$o_competition->date);
								
								$o_piscine = new piscine();
								$o_piscine->id = $o_competition->idPiscine;
								if($o_piscine->getByID()){
									$piscine = $o_piscine->nom;
									$lieu = $o_piscine->ville.' ('.$o_piscine->pays.')';
								}
							}
							
							$temps = '00:00.0';
							$minute = 00;
							$seconde = 00;
							$centieme = 00;
							
							if($ligne['temps'] >= 0){
								
								$tableauTemps = explode('.', $ligne['temps']);
								$timestamp = $tableauTemps['0'];
								$centieme = sprintf("%02d", $tableauTemps['1']);
								if($centieme == ''){$centieme =00;}
								$seconde = sprintf("%02d", ($timestamp % 60));
								$minute = sprintf("%02d", ($timestamp - $seconde) / 60);
								$temps = $minute.':'.$seconde.'.'.$centieme;

								
								echo '<table style="width:500px;margin-left : 125px;" cellspacing="0">
									<tr>
										<td colspan="3"><h2>'.$o_nage->nage.'</h2></td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;">Nom : </td>
										<td style="width:200px;" ><strong><a href="index.php?page=nageurs&id='.$ligne['idNageur'].'">'.strtoupper($ligne['nom']).' '.$ligne['prenom'].'</a></strong></td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;background-color : #a0a0a0">Date : </td>
										<td style="width:200px;background-color : #a0a0a0">'.$dateCompetition.'</td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;">Temps : </td>
										<td style="width:200px;">'.$temps.'</td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;background-color : #a0a0a0">Evenement : </td>
										<td style="width:200px;background-color : #a0a0a0">'.$nomCompetition.'</td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;">Piscine : </td>
										<td style="width:200px;">'.$piscine.'</td>
									</tr>
									<tr>
										<td style="width:100px;"></td>
										<td style="width:100px;background-color : #a0a0a0">Lieu : </td>
										<td style="width:200px;background-color : #a0a0a0">'.$lieu.'</td>
									</tr>
								</table><br/><br/>';
							
							}
							
						}
						
						
					}
				
				}
				
			}
		
		}
		
		
		

		$o_connexionBDD->fermerConnexion();
	?>
	
</div>