Bonjour à tous,

je suis entrain de developper un moteur de recherche qui contient deux champs de texte et une selecct box, c a d <select><option>......</select>

voila ce que j'ai fais :

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
<?php
$Countries = mysql_query("SELECT DISTINCT Country FROM leproperties ");
while(list($Country)=mysql_fetch_array($Countries)){ 
//echo $Country; 
} 
?>
<html> 
<form method="POST" action="">  
Min Price  : <input type="text" name="Minp"> <br>
Max Price  : <input type="text" name="Maxp"> <br>
<select name="Countylist">
 
<?php $Countries = mysql_query("SELECT DISTINCT Country FROM leproperties ");
while(list($Country)=mysql_fetch_array($Countries)){ 
echo "<option value=OpCountry>";
echo $Country;
echo "</option>";
}  ?>
</select>
<input type="SUBMIT" value="Search!">  
</form> 
</html> 
 
<?php 
 
// Récupère la variable 
$Minp = isset($_POST['Minp']) ? $_POST['Minp'] : ''; 
$Maxp = isset($_POST['Maxp']) ? $_POST['Maxp'] : ''; 
$SlctedCountry = isset($_POST['OpCountry']) ? $_POST['OpCountry'] : ''; 
// la requete mysql 
 
 
$sql = mysql_query("SELECT Reference, Price, Country FROM leproperties WHERE Price > $Minp AND Price < $Maxp AND Country=%'$SlctedCountry'% ORDER BY Price ASC  ") or die (mysql_error()); 
 
// affichage du résultat 
while(list($Reference, $Price, $Country)=mysql_fetch_array($sql)){ 
echo 'Resultat de la recherche: '.$Reference.', '.$Price.', '.$Country.' <br />'; 
} 
 
?>
Notez bien que lorsque retire la partie (AND Country=%'$SlctedCountry'% ) ts marche tres bien

Merci d'avance pour votre aide

!NyThaX&&,
Schpoontz