Results 1 to 4 of 4

Thread: Search text in database using Coldfusion

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Search text in database using Coldfusion

    I am developing a program that will search for multiple words in the database. My code should search for one word or if there is a perfect match of multiple words. i mean if i have database rows as
    1. Flash Player
    2. Adobe Flash Player
    then the code displays both for the search "flash Player", but when i search for "Adobe Player" then too it should display the same result, which my program code does not do. Anyone help me please.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Search text in database using Coldfusion

    Would like to see what actually your code looks like, and what data is it that yo are going to use and the result you are trying to get. Also did you try breaking the url.name into small pieces and then use LIKE to search for each piece.?


    You don't explain enough about what the data looks like and the result you are trying to get. But couldn't you break the url.name into pieces based on spaces and then select LIKE for each piece?

  3. #3
    Join Date
    Oct 2009
    Posts
    2

    Re: Search text in database using Coldfusion

    Here's what i did.
    Code:
    <cfparam name="URL.NAME" default="1" type="Any">
    <cfquery name="search" datasource="datasource">
    SELECT * FROM search WHERE NAME LIKE ="%#URL.NAME#%"ORDER BY DATE
    </cfquery>
    Still i am trying what you said, will post what i get.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Search text in database using Coldfusion

    Code:
    <cfparam name="searchStr" default=" ">
    <cfparam name="newArrayList" default=" ">
    <cfset newArrayList=ArrayNew(1)>
    <cfif isdefined("form.searchItems") AND form.searchItems neq "">
    	<cfset searchStr = #trim(form.searchItems)#>
    	<cfset searchstr = #lcase(searchStr)#>
    	 <cfif searchstr contains " "> 
    	 	<cfset searchStr = Replace(searchStr," ",",")>
    		<cfset newArrayList = ListToArray(searchstr)>
    		<cfif newArrayList[1] neq "">
    			<cfset item1 = #newArrayList[1]#>
    		</cfif>
    		<cfif searchstr contains ",">
    			<cfset item2 = #newArrayList[2]#>
    		</cfif>
    	 </cfif>
    </cfif>
    Try using this code, where i have broken it into two elements and then put them into an array. In case of any further assistance , please do post here.

Similar Threads

  1. Replies: 5
    Last Post: 10-10-2010, 04:30 AM
  2. Search Access Database in Windows XP
    By Doroteo in forum Windows Software
    Replies: 3
    Last Post: 04-11-2009, 11:19 PM
  3. I need a search function for my access database.
    By Superstar9 in forum Windows Software
    Replies: 3
    Last Post: 02-09-2009, 11:33 PM
  4. How to update two database tables coldfusion
    By Rixwel in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 03:13 PM
  5. Search Companion text search folder doesn't find all files
    By Hrishia in forum Windows XP Support
    Replies: 2
    Last Post: 27-11-2008, 10:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,541,045.97756 seconds with 17 queries