Treat the phrase/list of keywords coming in as a list:
<cfset keywords = " help me now">
<!--- assign to variable (TRIM! to remove lead/trailing spaces) --->
<cfset searchPhrase = #trim(keywords)#>
<!--- replace all space/multiple spaces with comma [delimiter] --->
<cfset searchPhrase = #REreplaceNoCase(searchPhrase, "[ ]+", ",", "ALL")#>
<!--- use this for your query to generate the Constraints --->
<cfloop from="1" to="#listLen(searchPhrase)#" index="counter">
AND columnName LIKE '%#listGetAt(searchPhrase,counter)#%'
</cfloop>
This code will produce the following code:
AND columnName LIKE '%help%'
AND columnName LIKE '%me%'
AND columnName LIKE '%now%'
Use the listLen function to get number of keywords if you still need that.
Obviously, adjust the code for "OR" instead of "AND" etc, but you get the idea.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics.
http://www.fusionauthority.com/signup.cfm