HowdeeDoodee Posted July 6, 2007 Share Posted July 6, 2007 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 ; Quote Link to comment https://forums.phpfreaks.com/topic/58696-how-do-i-give-user-selection-of-fields-to-search-with-full-text-boolean/ Share on other sites More sharing options...
Illusion Posted July 6, 2007 Share Posted July 6, 2007 Not with the help of mysql, U write some php code to check whether the check box checked or not if checked then append a match conditon for the query, like that for all the check boxes. Quote Link to comment https://forums.phpfreaks.com/topic/58696-how-do-i-give-user-selection-of-fields-to-search-with-full-text-boolean/#findComment-291138 Share on other sites More sharing options...
HowdeeDoodee Posted July 6, 2007 Author Share Posted July 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/58696-how-do-i-give-user-selection-of-fields-to-search-with-full-text-boolean/#findComment-291152 Share on other sites More sharing options...
Illusion Posted July 6, 2007 Share Posted July 6, 2007 $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 ..... Quote Link to comment https://forums.phpfreaks.com/topic/58696-how-do-i-give-user-selection-of-fields-to-search-with-full-text-boolean/#findComment-291237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.