I have a search input, I explode user input into array (key words).
ex. web programmer
-> $search[0]=>web
, $search[1]=>programmer
How do I loop the array into the query for search?
$nums=count($search);
for($n=0; $n<$nums; $n++){
$SQL=$db->prepare("SELECT * FROM post
WHERE title LIKE :search_1 OR classify LIKE :search_2");
$SQL->bindValue(':search_1', "%".$search[$n]."%", PDO::PARAM_STR);
$SQL->bindValue(':search_2', "%".$search[$n]."%", PDO::PARAM_STR);
$SQL->execute();
}
$db=NULL;
So it will search 'web' and 'programmer' these 2 words from db