Mysql
 sql >> Database >  >> RDS >> Mysql

Risultato vuoto della query SQL sul codice php

prova questo

    $query='SELECT DISTINCT publication_id FROM publications WHERE 1=1 ';
 if(isset($keyword_label) && isset($publication_year)){
 $query.=' AND (publication_key_1="'.$keyword_label.'" OR publication_key_2="'.$keyword_label.'" OR publication_key_3="'.$keyword_label.'" OR 
publication_key_4="'.$keyword_label.'" OR publication_key_5="'.$keyword_label.'" OR publication_key_6="'.$keyword_label.'" OR
publication_key_7="'.$keyword_label.'") AND publication_year="'.$publication_year.'"';
}
if(isset($publication_year)){
$query.=' AND publication_year="'.$publication_year.'"';
}
if(isset($keyword_label)){
$query.=' AND publication_key_1="'.$keyword_label.'" OR publication_key_2="'.$keyword_label.'" OR publication_key_3="'.$keyword_label.'" OR 
publication_key_4="'.$keyword_label.'" OR publication_key_5="'.$keyword_label.'" OR publication_key_6="'.$keyword_label.'" OR
publication_key_7="'.$keyword_label.'"';
}
$query.=' ORDER BY publication_year DESC';

MODIFICA:

prova a cambiarlo

   if(!$result) {

a questo

  if( $result == false ) {