0
Good night consecrated, I have a search page, in which I want that when someone searches something like "i3 memory screen cabinet" appear all the items available in the table with respect to these searched items, for this I must use the explode in the variable that recovers the values and put in the LIKE, the problem is there, it creates an array, that I have no way of knowing how many values will have depending on the user’s search, if I put LIKE 'variable[0]' it goes and even without the 0, but returns only the first entered value, I wonder if have a way to pull others so that does not pull the whole table due to an empty array. Follow the Code:
<?php
$buscaexp = explode(" ",$buscanaurl);
$procura = $conn->prepare("SELECT * FROM produtos WHERE nome LIKE '%$buscaexp[0]%' OR (nome LIKE '%$buscanaurl%')");
$procura->execute();
?>
follows link to anyone who wants to look http://www.tcc2016.96.lt/busca?busca=memoria+i3
The duplicate links somehow helped me a little, however I still could not make it work, maybe because PDO needs something that I still do not know what it is
– Senpai
is like this: for($i = 0; $i < Count($buscaexp); $i++) $param = "LIKE name '%". $buscaexp[$i]." %'"; //var_dump($buscaexp); $procura = $Conn->prepare("SELECT * FROM products WHERE ". $param); $procura->execute();var_dump($procura);
– Senpai
and in the var_dump output this way: Object(Pdostatement)#1 (1) { ["queryString"]=> string(45) "SELECT * FROM products WHERE NAME LIKE '%i3%'" } even when I search for more than one product in the bar is as if it only searches for the last array
– Senpai