0
$termos = (explode('/', implode('/', $_GET['tipo'])));
print_r($termos);
Array
(
[0] => CASA
[1] => CASA EM CONDOMINIO
[2] => COBERTURA
)
I have a syntax error in this SQL that makes loops to add as many terms are needed that are captured inside array
above:
$sql = array('0');
foreach($termos as $termo){
$sql[] = 'CATEGORIA LIKE %'.$termo.'%';
}
$sql = 'SELECT * FROM imovel WHERE ' .implode(' OR ', $sql);
Syntax error or access Violation: 1064
I can’t figure out which syntax error is alerted.
Didn’t forget to put single quotes on the term of
LIKE
? Like:CATEGORIA LIKE '%CASA%'
.– Wakim
Echo this SQL string. This
array(0)
, for example, would not be producing something likeWHERE 0 OR CATEGORIA LIKE...
?– Bruno Augusto
@Brunoaugusto, this one
WHERE 0 OR ...
works. Here is an Sqlfiddle: http://sqlfiddle.com/#! 2/1c439/3– Wakim
Link did not open as expected.
– Bruno Augusto
Jeez, it’s out of the air... When you come back you’ll see how it works.
– Wakim