Salut tout le monde!
J'ai une page contenant un formulaire par lequel je passe pour faire une recherche dans ma bdd. Je coche sur quelle table je veux rechercher et apres j'affine ma recherche en allant sur différents champs. Mon soucis est que les champs de mes tables sur lesquels je recherche ont le meme nom...Si je renomme mes champs, je ne sais pas comment je vais pouvoir m'y prendre pour ma requete...Y a t-il une autre solution?
Pour info, mon code :
//Récupération des valeurs des champs:
//Tables
$flag='';
$from='';
if(isset($_POST['recap_ameliorations']))
{
$from=" FROM recap_ameliorations ";
$flag='1';
}
if(isset($_POST['recap_observations']))
{
if($flag=='1') $from.=" , recap_observations ";
else
$from.=" FROM recap_observations ";
}
//Mot clé
$flag='';
$where='';
if(!EMPTY($_POST['mot_cle']))
{
$where=' WHERE description OR cause_probable OR proposition_amelioration LIKE \''.$_POST['mot_cle'].'\' ';
$flag='1';
}
//Agence concernée
if(!EMPTY($_POST['agence_concernee']))
{
if($flag=='1') $where.=' AND agence_concernee LIKE \''.$_POST['agence_concernee'].' \' ';
else
$where.=' WHERE agence_concernee LIKE \''.$_POST['agence_concernee'].' \' ';
$flag='1';
}
//Processus concerné
if(!EMPTY($_POST['processus_concerne']))
{
if($flag=='1') $where.=' AND processus_concerne LIKE \''.$_POST['processus_concerne'].' \' ';
else
$where.=' WHERE processus_concerne LIKE \''.$_POST['processus_concerne'].' \' ';
$flag='1';
}
//Responsable
if(!EMPTY($_POST['resp']))
{
if($flag=='1') $where.=' AND resp LIKE \''.$_POST['resp'].' \' ';
else
$where.=' WHERE resp LIKE \''.$_POST['resp'].' \' ';
$flag='1';
}
//Etat des actions
if(!EMPTY($_POST['etat_action']))
{
if($flag=='1') $where.=' AND etat_action LIKE \''.$_POST['etat_action'].' \' ';
else
$where.=' WHERE etat_action LIKE \''.$_POST['etat_action'].' \' ';
$flag='1';
}
//Numéro
if(!EMPTY($_POST['numero']))
{
if($flag=='1') $where.=' AND numero LIKE \''.$_POST['numero'].' \' ';
else
$where.=' WHERE numero LIKE \''.$_POST['numero'].' \' ';
$flag='1';
}
Merci d'avance