Hello-
I'm writing a search page using Mysql full-text boolean search to search thru data. What I have written works if the user enters the boolean operators, like '+', in the search field (if I dont'use the "qualifier" field in my code below), but I'm trying to make it more user friendly so that the user can select to use all the search terms or any of the search terms rather than having to enter the boolean operators in front of each search term in the search form. But I can't get my code to work. It doesn't return any results. Below is my code for my search form and the page that does the searching. What am I doing wrong? Is there a bettwer way to do this? Any help would be greatly appreciated.
// the search form
<form action="dothesearch.php" method="POST">
<input type="text" name="keywords">
<input type="radio" name="qualifier" value="all">Search using all of your keywords
<input type="radio" name="qualifier" value="any">Search using any of your keywords
<input type="submit" name="submit" value="SEARCH"> <input type="reset" value="Clear form">
//do the search and search using all the terms if 'all'
if ($qualifier == "all"){
$keywords=explode(" ",$keywords);
//add + operator to each keyord
foreach ($keywords as &$keywords) {
$keywords = "+".$keywords." ";
}
}
$query = mysql_query("SELECT *, MATCH(title,companyname2,city2,description) AGAINST('$keywords' IN BOOLEAN MODE) as relevance FROM joblistings WHERE MATCH(title,companyname2,city2,description) AGAINST('$keywords' IN BOOLEAN MODE) and approved='1' and inactive ='0'");