I currently have a simple search engine that searches for a column in my database based on user input:
$search = $_GET['search']; $terms = explode(" ", $search); $sql = "SELECT * FROM people WHERE lname LIKE :search"; $q = $conn->prepare($sql) or die("failed!"); $q->bindValue(':search',"%".$search."%",PDO::PARAM_STR); $q->execute(); if ($q){
He is currently looking for terms in general, for example, a โred tableโ returns a result, but a โred tableโ returns nothing
Any ideas? Any help is much appreciated!
EDIT:
Since then I changed it to this ...
$search = $_GET['search']; $terms = explode(" ", $search); $sql = "SELECT * FROM people WHERE MATCH (lname,fname) AGAINST (:search IN BOOLEAN MODE)"; $q = $conn->prepare($sql) or die("failed!"); $q->bindValue(':search',"%".$search."%",PDO::PARAM_STR); $q->execute();
it seems to be working fine now, if someone can offer a better solution, I would be very grateful!
neeko source share