Filtre de recherche par prix
Posté : 27 févr. 2009, 11:19
Bonjour, je suis en train de faire un filtre multi-critère, j'ai 4 tables, une table c'est les annonces et les autres sont les critères (ville, type, état ). Donc j'ai fait des menu qui reprennent les informations de ville, type et etat, a ce niveau pas de souci. si je cherche les annonces dans une ville c'est en ordre. Par contre j'ai un souci pour la recherche d'annonce par tranche de prix. Je veux faire un menu du style :
<500
500-1000
1500-2000
>2000
il faudrait qu'il filtre les annonces avec ces critères de prix. Mon problème est qu'il filtre uniquement par tranche et non tout les tranches.
Ou dois-je mettre mes conditions?
mon sql :
mon form :
Merci d'avance de votre aide...
<500
500-1000
1500-2000
>2000
il faudrait qu'il filtre les annonces avec ces critères de prix. Mon problème est qu'il filtre uniquement par tranche et non tout les tranches.
Ou dois-je mettre mes conditions?
mon sql :
Code : Tout sélectionner
$query_rsannonce = sprintf("SELECT * FROM m_annonce WHERE id_type = %s OR id_ville = %s OR id_budget = %s OR id_etat = %s", Code : Tout sélectionner
<form id="rech" name="rech" method="get" action="index.php">
<p> </p>
<table width="69%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="102" height="20" class="titre_index"><div align="center">Type</div></td>
<td width="124" class="titre_index"><div align="center">Etat</div></td>
<td width="121" class="titre_index"><div align="center">Votre budget</div></td>
<td width="185" class="titre_index"><div align="center">Localité</div></td>
<td width="153"> </td>
</tr>
<tr align="center">
<td><label>
<select name="type" id="type">
<option value="">Indifférent</option>
<?php
do {
?>
<option value="<?php echo $row_rstype['id_type']?>"><?php echo $row_rstype['type']?></option>
<?php
} while ($row_rstype = mysql_fetch_assoc($rstype));
$rows = mysql_num_rows($rstype);
if($rows > 0) {
mysql_data_seek($rstype, 0);
$row_rstype = mysql_fetch_assoc($rstype);
}
?>
</select> </label></td>
<td><label>
<select name="etat" id="etat">
<option value="">Indifférent</option>
<?php
do {
?>
<option value="<?php echo $row_rsetat['id_etat']?>"><?php echo $row_rsetat['etat']?></option>
<?php
} while ($row_rsetat = mysql_fetch_assoc($rsetat));
$rows = mysql_num_rows($rsetat);
if($rows > 0) {
mysql_data_seek($rsetat, 0);
$row_rsetat = mysql_fetch_assoc($rsetat);
}
?>
</select> </label></td>
<td><label>
<select name="budget" id="budget">
<option value="">Indifférent</option>
<?php
do {
?>
<option value="<?php echo $row_rsbudget['id_budget']?>"><?php echo $row_rsbudget['budget']?></option>
<?php
} while ($row_rsbudget = mysql_fetch_assoc($rsbudget));
$rows = mysql_num_rows($rsbudget);
if($rows > 0) {
mysql_data_seek($rsbudget, 0);
$row_rsbudget = mysql_fetch_assoc($rsbudget);
}
?>
</select> </label></td>
<td><label>
<select name="ville" id="ville">
<option value="">Indifférent</option>
<?php
do {
?><option value="<?php echo $row_rsville['id_ville']?>"><?php echo $row_rsville['ville']?></option>
<?php
} while ($row_rsville = mysql_fetch_assoc($rsville));
$rows = mysql_num_rows($rsville);
if($rows > 0) {
mysql_data_seek($rsville, 0);
$row_rsville = mysql_fetch_assoc($rsville);
}
?>
</select> </label></td>
<td><label>
<input type="submit" name="submit" id="submit" value="Rechercher" />
</label></td>
</tr>
<tr align="center">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr align="center">
<td colspan="5"><hr /></td>
</tr>
</table>
<p> </p>
<p class="titre">Résultats : </p>
<?php do { ?>
<table width="65%" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="18%" class="titre_index"><p><?php echo $row_rsannonce['titre']; ?><br />
<span class="text"><?php echo KT_formatDate($row_rsannonce['date']); ?></span></p> </td>
<td width="24%" class="text"><?php echo $row_rsannonce['description']; ?></td>
<td width="20%" class="text"></td>
<td width="3%" class="text"> </td>
<td width="18%" class="text"></td>
<td width="2%" class="text"> </td>
<td width="15%" class="text"><?php echo $row_rsannonce['prix']; ?>.-</td>
</tr>
<tr>
<td colspan="7" class="titre_index"><hr /></td>
</tr>
</table>
<?php } while ($row_rsannonce = mysql_fetch_assoc($rsannonce)); ?><p> </p>
</form>