Hello, I'm doing a search engine, but I'm kind of a layperson about Querys. The method that I thought to refine the search, which in the case would be a simple search between two fields of a table with several products, was to be eliminated through selects.
$varBusca = str_replace(array(',',' ','.','%','-','/','\'),'-',$_POST['busca']);
$varBusca = explode('-',$varBusca);
/* metodo 1 */
$query_busca="";
$pos_busca=0;
foreach($varBusca as $chave)
{
if ($pos_busca==0){
$query_busca.="SELECT * FROM ( # ) WHERE pro_nome LIKE '%$chave%' OR pro_descricao LIKE '%$chave%'";
}else{
$query_inserida="SELECT * FROM ( # ) WHERE pro_nome LIKE '%$chave%' OR pro_descricao LIKE '%$chave%'";
$query_busca=str_replace('#',$query_inserida,$query_busca);
}
$pos_busca++;
}
$query_busca=str_replace('#','produtos',$query_busca);
echo $query_busca;
I break the search string and search for each word. But this query ends up returning no items from the table, even though there is some item with some query word.
Any suggestions?