Jump to content

How do I give user selection of fields to search with Full Text - Boolean?


HowdeeDoodee

Recommended Posts

I want to give the user the option of searching a combination of the fields $Topic, $Subtopic, $Theswords in Boolean/Full Text. The problem is if I make any of the fields empty prior to the query, I get a MySql syntax error message. The user has the option of selecting fields via checkboxes, but when the field is not selected the user will get the error message. Is there any way of avoiding the error message when a field is not selected to be searched? Thank you in advance for any replies.

 

 

$query = "SELECT * FROM `View2_CondFT` WHERE MATCH($TopicFieldSelect, $SubtopicFieldSelect, $TheswordsFieldSelect) AGAINST ('$terms[0]' IN BOOLEAN MODE) 
AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[1]' IN BOOLEAN MODE) 
AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[2]' IN BOOLEAN MODE) 
AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[3]' IN BOOLEAN MODE) 
AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[4]' IN BOOLEAN MODE) 
AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[5]' IN BOOLEAN MODE) 
ORDER BY `Lnum` ASC ;

Thank you Illusion, you are right I posted this question to the wrong forum. Oops.

 

Is there any way you could further explain what you mean by the part of your statement shown below?

 

"then append a match conditon for the query, like that for all the check boxes."

 

Thank you again for the response.

$query = "SELECT * FROM `View2_CondFT` ";
$isand=0;
if(isset($terms[1]) and $isand==0)
{
$query=$query."MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[1]' IN BOOLEAN MODE)";
$isand=1;
}
if(isset($terms[2]) and $isand==0)
{
$query=$query."MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[1]' IN BOOLEAN MODE)";
$isand=1;
}
elseif(isset($terms[2]) and $isand==1)
{
$query=$query."AND MATCH($Topic, $Subtopic, $Theswords) AGAINST ('$terms[1]' IN BOOLEAN MODE)";
}

like that test for all check boxes and built the query..........I am not reviewd it .....

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.