I have a search form that would like the users to search multiple terms. I’m currently using PHP PDO and I’m still learning… I was wondering if someone can tell me what I’m doing wrong here.
$varSearch = @$_GET['dms'];
$varTerm = explode(" ", $varSearch);
$termArray = array();
foreach($varTerm as $term){
$term = trim($term);
if(!empty($term)){
$termArray[] = "name LIKE '%".$term."%' OR tags LIKE '%".$term."%'";
}
}
$implode = implode(' OR ', $termArray);
$sql = $dbh->prepare("SELECT * FROM table WHERE ?");
$sql->execute(array($implode));
If anyone else needs this answer too…