Hi all,

Je cherche à faire un formulaire de recherche, mais je rencontre un problème avec 3 checkbox.

Je voudrais faire une requête selon la ou les checkbox sélectionner, donc g fais une boucle Switch/case :

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
switch($typeBoat)
	{
	 case mono:
		 $query="SELECT ID, name, cabines, pers, loa, motorisation, basedepus, hull FROM boat WHERE hull LIKE '%mono%' AND basedepus LIKE '%".$userZone."%' ORDER BY loa DESC";
		 break;
	 case cata:
		 $query="SELECT ID, name, cabines, pers, loa, motorisation, basedepus, hull FROM boat WHERE hull LIKE '%cata%' AND basedepus LIKE '%".$userZone."%' ORDER BY loa DESC";
		 break;
	case motoryacht:
		$query="SELECT ID, name, cabines, pers, loa, motorisation, basedepus, hull FROM boat WHERE hull LIKE '%motoryacht%' AND basedepus LIKE '%".$userZone."%' ORDER BY loa DESC";
		  break;
	 default:
		 $query="SELECT ID, name, cabines, pers, loa, motorisation, basedepus, hull FROM boat WHERE (hull LIKE '%mono%' OR hull LIKE '%cata%' OR hull LIKE '%motoryacht%') AND basedepus LIKE '%".$userZone."%' ORDER BY loa DESC";
		 break;
}
Là je ne gère que le cas ou seulement une est sélectionnée.

Comment faire pour gérer les cas où 2 d'entre elles ou les Trois ensembles sont sélectionnées ?

Merci pour vos réponses !