I have a select where like query for a seach form which is as follows:
<?php
$bucketsearch = sanitizeone($_POST["bucketsearch"], "plain");
$bucketsearch = strip_word_html($bucketsearch);
?>
if(isset($_POST['search'])){
$result=MYSQL_QUERY( "SELECT * FROM buckets where bucketname like '%$bucketsearch%' order by bucketname");
}else{
$result=MYSQL_QUERY( "SELECT * FROM buckets order by bucketname");
}
My problem is that if someone searches for instance for “apple and pear” i do not get any results that contain any of the words, i can only make it return results (well 1 result) with all the words in it.
Can anyone help me make this search a bit more versitle??
Thanks in advance.
So you want an AND search using each of the words entered, rather than the exact string? Howabout something like this:
this will give you a query like:
change the AND to an OR if you want to match any of the search terms rather than all. Further improvements could involve defining some stop words like ‘and’ to give better results.