Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:33:55+00:00 2026-06-04T04:33:55+00:00

I’m trying to upgrade a Coldfusion8/MySQL site. The site has a complex search which,

  • 0

I’m trying to upgrade a Coldfusion8/MySQL site. The site has a complex search which, (among other criteria) takes text strings and searches these in a keyword table.

I don’t want to do a FULLTEXT search, because the full query has a lot of extra conditions. What I’m looking for is to make the following more “dynamic”, that is not limit myself to xy words and thereby maybe shortening this a bit (the full search has plenty of blocks like this).

So, say I have a search string like

I'm looking for something

I’m currently doing this:

<!--- params --->
<cfparam name="s01" default="">
<cfparam name="s02" default="">
<cfparam name="s03" default="">    
<cfparam name="s04" default="">
<cfparam name="s05" default="">

<!--- get length of search string --->
<cfset howManyWords = ListLen(textSearch," ")>

<!--- assign words to params --->
<cfif howManyWords gt 0><cfset s01 = trim(ListGetAt(textSearch, 1," "))></cfif>
<cfif howManyWords gt 1><cfset s02 = trim(ListGetAt(textSearch, 2," "))></cfif>
<cfif howManyWords gt 2><cfset s03 = trim(ListGetAt(textSearch, 3," "))></cfif>
<cfif howManyWords gt 3><cfset s04 = trim(ListGetAt(textSearch, 4," "))></cfif>
<cfif howManyWords gt 4><cfset s05 = trim(ListGetAt(textSearch, 5," "))></cfif>

In my search query, I’m matching the search strings to three database fields:

...
<cfif textSearch neq "">
    <cfif s01 neq "">AND (a.textSearch LIKE "%#s01#%" OR a.textSearch_xl LIKE "%#s01#%" OR a.ean = "#s01#")</cfif>
    <cfif s02 neq "">AND (a.textSearch LIKE "%#s02#%" OR a.textSearch_xl LIKE "%#s02#%" OR a.ean = "#s02#")</cfif>
    <cfif s03 neq "">AND (a.textSearch LIKE "%#s03#%" OR a.textSearch_xl LIKE "%#s03#%" OR a.ean = "#s03#")</cfif>
    <cfif s04 neq "">AND (a.textSearch LIKE "%#s04#%" OR a.textSearch_xl LIKE "%#s04#%" OR a.ean = "#s04#")</cfif>
    <cfif s05 neq "">AND (a.textSearch LIKE "%#s05#%" OR a.textSearch_xl LIKE "%#s05#%" OR a.ean = "#s05#")</cfif>
</cfif>
...

Question:
Is there a way to make this more dynamic, for example with a loop, so I’m not stuck with 5 words? How would I preset the param values in this case?

Thanks for help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:33:56+00:00Added an answer on June 4, 2026 at 4:33 am

    You can just explode the search term by looping over it as a list within the query, you should also be using query parameters to prevent SQL injection attacks.

    <cfloop list="#textSearch#" index="word" delimiters=" ">
      AND (
        a.textSearch LIKE <cfqueryparam cfsqltype="cfsql_varchar" value="%#word#%"> 
        OR a.textSearch_xl LIKE <cfqueryparam cfsqltype="cfsql_varchar" value="%#word#%">  
        OR a.ean = <cfqueryparam cfsqltype="cfsql_varchar" value="#word#"> 
      )
    </cfloop>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.