limsa | Bonjour @ tous, j'ai codé un moteur de recherche en php qui ne cherche que sur une seule table ici t_signalisation
l'utilisateur peut rentrer a la fois 0 criteres de recherche et dans ce cas affiche toutes les signalisation ou une combinaison des 16 criteres de recherche pour l'affinage de la requete. Si le champs est renseigné, alors j'ajoute une condition AND dans la requete mysql en procédant par concaténation cependant j'ai cette erreur qui est affichée:
Citation :
Notice: Use of undefined constant query - assumed 'query' in c:\program files\easyphp1-7\www\suivianous\traitementrecherchesig.php on line 321
ERREUR" query You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'sig_TypeResolution LIKE 1' at line 7
|
Voici le code correspondant.
Merci d'avance pour votre aide
Code :
- if($appsig !=="" ){
- $requete1= "SELECT app_Id FROM t_application
- WHERE app_Libelle = '$appsig'";
- $query1 = mysql_query($requete1) or die ('ERREUR" '.requete1.' '.mysql_error());
- while ($row=mysql_fetch_array($query1)){
- $value1= $row["app_Id"];
- }
- }
- if($initsig !=="" ){
- $requete2= "SELECT ini_id FROM t_initiateur
- WHERE ini_libelle = '$initsig'";
- $query2 = mysql_query($requete2) or die ('ERREUR" '.requete2.' '.mysql_error());
- while ($row=mysql_fetch_array($query2)){
- $value2= $row["ini_id"];
- }
- }
- if($affsig !=="" ){
- $requete3= "SELECT uti_IdUtilisateur FROM t_utilisateur
- WHERE uti_NomUtilisateur = '$affsig'";
- $query3 = mysql_query($requete3) or die ('ERREUR" '.requete3.' '.mysql_error());
- while ($row=mysql_fetch_array($query3)){
- $value3= $row["uti_IdUtilisateur"];
- }
- }
- if($statutsig !=="" ){
- $requete4= "SELECT st3_StatutId FROM t_statutsS3A
- WHERE st3_Libelle = '$statutsig'";
- $query4 = mysql_query($requete4) or die ('ERREUR" '.requete4.' '.mysql_error());
- while ($row=mysql_fetch_array($query4)){
- $value4= $row["st3_StatutId"];
- }
- }
- if($resolsig !=="" ){
- $requete5= "SELECT type_id FROM t_typeresolution
- WHERE type_libelle = '$resolsig'";
- $query5 = mysql_query($requete5) or die ('ERREUR" '.requete5.' '.mysql_error());
- while ($row=mysql_fetch_array($query5)){
- $value5= $row["type_id"];
- echo $value5;
- }
- }
- // sinon, on regarde si la variable $debut (le x de notre LIMIT) n'a pas déjà été déclarée, et dans ce cas, on l'initialise à 0
- if (!isset($_GET['debut'])) $debut = 0;
- else $debut = $_GET['debut'];
- $query = "SELECT sig_ApplicationId, sig_statutID, sig_NumeroSignalisation, sig_Titre,DATE_FORMAT(sig_DateReception,'%d/%m/%Y') AS sig_DateReception, DATE_FORMAT(sig_DateDebut,'%d/%m/%Y') AS sig_DateDebut, sig_IdAffectation,sig_ReferenceHDE,sig_ReferenceMOA, sig_PMOA, sig_StatutID
- FROM t_signalisation
- WHERE sig_Titre=sig_Titre";
- $counter = 0;
- if ($numsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_NumeroSignalisation like '%$numsig%'";
- $counter++;
- }
- if ($titresig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_Titre like '%$titresig%'";
- $counter++;
- }
- if ($descsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_Description like '%$descsig%'";
- $counter++;
- }
- if ($comsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_Commentaire like '%$comsig%'";
- $counter++;
- }
- if ($appsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_ApplicationId like '%$value1%'";
- $counter++;
- }
- if ($versionlot !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_Version like '%$versionlot%'";
- $counter++;
- }
- if ($resolsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_TypeResolution LIKE $value5";
- $counter++;
- }
- if ($initsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_Initiateur like '%value2%'";
- $counter++;
- }
- if ($affsig !== "" ) {
- if ($counter>=0) //$query .= "and";
- $query .= "AND sig_IdAffectation like '%$value3%'";
- $counter++;
- }
- if ($prioritesig !== "" ) {
- if ($counter>=0) //$query .= "and";
- $query .= "AND sig_Priorite like '%$prioritesig%'";
- $counter++;
- }
- if ($refhdesig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_ReferenceHDE like '%$refhdesig%'";
- $counter++;
- }
- if ($refsuexsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_ReferenceSuEx like '%$refsuexsig%'";
- $counter++;
- }
- if ($pmoasig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_PMOA like '%$pmoasig%'";
- $counter++;
- }
- if ($statutsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_StatutID like '%$value4%'";
- $counter++;
- }
- if ($refmoasig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_ReferenceMOA like '%$refmoasig%'";
- $counter++;
- }
- if ($refitsig !== "" ) {
- if ($counter>=0) //$query .= " and ";
- $query .= "AND sig_ReferenceFO like '%$refitsig%'";
- $counter++;
- }
- // on exécute la requête
- $req = mysql_query($query)or die ('ERREUR" '.query.' '.mysql_error());
|
|