Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Resultado vazio da consulta SQL no código php


tente isso
    $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';

EDITAR:

tente mudar isso
   if(!$result) {

para isso
  if( $result == false ) {