Possible Duplicate:
How do I create a PDO parameterized query with a LIKE statement in PHP?
At the moment I have a very simple search engine which uses the old mysql_* queries and also uses "like" in the query, i understand this is now outdated and using like queries can get slow as the database grows?
I am looking for some ideas on how I can create a search engine using PDO as it offers more protection than i currently have, I have researched about using MATCH and AGAINST in a query,to search the "title" and "description" columns in my database, but as i am a beginner i am unsure of where to start.
I get stuck on trying to figure out how to implement a search query, and getting the search to work if the user enters multiple keywords
any help is much appreciated, i understand this might be a big ask of someone to explain this to me but i am doing as much as i can to learn as i am a student and working on a project
Thankyou for anyones help!
THIS IS PART OF MY CURRENT CODE WHICH I WOULD LIKE TO CHANGE AND UPDATE TO SOMETHING MORE SECURE AND WITH BETTER SEARCH FACILITIES:
$query = "SELECT * FROM people WHERE ";
foreach ($terms as $each){
$i++;
if ($i == 1)
$query .= "lname LIKE '%$each%' ";
if($i == 1 && $_GET['category'] != '') {
$query .= "AND category = '$chosencategory' ";
}
else
$query .= "AND lname LIKE '%$each%' ";
if($_GET['price'] != '') {
$query .= " ORDER BY price $price";
}
echo $query;
}