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
|
function Requete ($champ,$table,$Colonne)
{
global $PrixMini,$PrixMaxi;
$TableauChamp=explode(" ",$champ);
$NbMotsChamp=sizeof($TableauChamp);
$ReqChamp="";
/***
Sinon, il suffit de créer un compteur dans la boucle ($i++), puis avant la boucle obtenir le nombre total d'élément ( count() ),
et dans la boucle faire une comparaison.
Si la valeur du compteur == au nombre total => pas de union
**/
foreach($TableauChamp as $key=>$mot)
{
$mot=trim($mot);
$ReqChampinter="(SELECT * from $table WHERE $Colonne like '%$mot%' AND Prix Between '$PrixMini' AND '$PrixMaxi' LIMIT 30)";
$ReqChamp.=$ReqChampinter." UNION ";
}
$ReqChamp = rtrim($ReqChamp, 'UNION ');
return $ReqChamp;
}
$RequeteRefESI=Requete($RefESI,"inventaireproduits","RefESI");
$RequeteRefConstructeur=Requete($RefConstructeur,"inventaireproduits","RefConstructeur");
$RequeteDescription=Requete($Description,"inventaireproduits","Designation");
$BigRequete=$RequeteRefESI." UNION ".$RequeteRefConstructeur." UNION ".$RequeteDescription." ORDER BY IdProduit ASC";
$resultat= mysql_query($BigRequete); |
Partager