I have a site that will have both and simple simple search and an advanced search feature. The simple search uses the following code:
$query="SELECT *, MATCH (description,specialties,name,street,city,zip,phone,dress,other) AGAINST ('$searchstring') AS 'score' FROM store WHERE MATCH(description,specialties,name,street,city,zip,phone,dress,other) AGAINST('$searchstring' IN BOOLEAN MODE)ORDER by score DESC ";
I made a fulltext index in phpmyadmin that includes those columns.
Now I want to make an advanced search. I used the following code to allow for this:
<?
$name=$_POST['name'];
$speciality=$_POST['speciality'];
$zip=$_POST['zip'];
$city=$_POST['city'];
$string = name;
$searchstring = $name;
}
else{
}
if ($speciality != null ){
$string = $string . "," . specialties;
$searchstring = $searchstring . " " . $speciality;
}
else {
}
if ($city != null ) {
$string = $string . "," . city ;
$searchstring = $searchstring . " " . $city ;
}
else {
}
if ($zip != null ) {
$string = $string . "," . zip ;
$searchstring = $searchstring . " " . $zip ;
}
else {
}
echo "$string <br>";
echo "$searchstring";
?>
<? mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to Connect to database");
$query="SELECT *, MATCH ($string) AGAINST ('$searchstring') AS 'score' FROM store WHERE MATCH($string) AGAINST('$searchstring' IN BOOLEAN MODE)ORDER by score DESC ";
Basically this just allows the search to know what columns to search in and what characters to search for.
The problem is that when I run this i get a "Can't find FULLTEXT index matching the column list" error because the fulltext index that i made in phpmyadmin for the simple search does not match the one that will be used in this advanced search.
Does what I'm trying to do make sense? Am i going about this the wrong way? Any suggestions?