Searching for any keyword in a phrase
2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 11, 2015 (RSS)
By JeffC - November 11, 2015
Please could someone tell me the correct way to search for any keyword contained in a phase.
Using the form below if a user was to search for "Restaurant in London" a result would appear only if one of the fields contained "Restaurant in London". I would like a result to appear if at least one of the words appeared, ie if they search for just "London"
<form method="POST" action="/restaurants.php">
<input type="text" name="title,short_description,content,address,town,county_keyword" value="">
<input type="submit" name="submit" value="Search Reviews">
</form>
Thank you
By Damon - November 11, 2015
Hi Jeff,
The search doesn't work this way otherwise if a user searched using the phrase "Restaurant in London", you would get search results on any of the words like "in".
One method to do this would be to write custom code to break the search query up by spaces, then put the individual words into an array. Next a custom WHERE statement using LIKE to return the results. A further step would be to create a list of common words to remove from the search array such as: in, a, the, it, is, etc.
If you are interested in getting this done through consulting, send Ross an email with details to consulting@interactivetools.com.
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/