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
| <?php
//variable de recherche et d'ordre
$ordre2= ' ORDER BY `' . mysql_real_escape_string($ordre) . '` ';
$motrecherche= '';
$searchpar=$_REQUEST['par'];
$mot=$_REQUEST['motclef'];
$mot=mysql_real_escape_string($mot);
//verification que la recherche ne soit pas vide
if (isset($mot)){
$motrecherche= 'WHERE `' . mysql_real_escape_string($searchpar) . '` LIKE "%' .$mot . '%"';
}
// verification si l'option rechercher partout est validé
if($searchpar=='partout'){
$motrecherche='WHERE designation LIKE "%' . mysql_real_escape_string($mot) . '%"
or appellation LIKE "%' . mysql_real_escape_string($mot) . '%"
or constr LIKE "%' . mysql_real_escape_string($mot) . '%"
or fournisseur LIKE "%' . mysql_real_escape_string($mot) . '%"';
}
//requete avec tri et recherche
$sql= "SELECT * FROM produits INNER JOIN fournisseur,constructeur produits.importateur=fournisseur.idfourni
AND produits.constructeur=constructeur.idconstr ".$motrecherche.$ordre2; |