Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape Q about search...

    Hi all...
    I did a search form...
    when user write in the form: Moscow
    The form give him all the results with the word Moscow

    But when he write Moscow London the result is 0 entries...

    BUT in the table we can find Moscow to London

    And the search ignores this. cuz he search's full frase...

    What should i do th show the user Moscow to London if he search Moscow london...

    Here's the code:

    Code:

    strSQL = "SELECT marsh, polnyi, id " _
    & "FROM Question " _
    & "WHERE marsh LIKE '%" & Replace(strpoisk, "'", "''") & "%' " _
    & "OR polnyi LIKE '%" & Replace(strpoisk, "'", "''") & "%' " _
    & "ORDER BY id;"

    Sorry for my English... and thank for your help!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Split the keyword by space to have an array of keywords and then form the LIKE condition for each keyword
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your Re...

    can you show me please how to do this...
    I already figured it out that i need to split the words by space....

    But i don't know how to...

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe something like this

    Code:
    <%
    If Len(Request.Form) > 0 Then
    	term = Trim(Request.Form("search"))
    	term = Replace(term,"'","''")
    	
    	If InStr(term," ") > 0 Then
    		term = Split(term," ")
    		
    		For x=0 to Ubound(term)
    			If x > 0 Then
    					clause = clause & " AND"
    				End If
    			clause = clause & " location LIKE '%" & term(x) & "%'"
    		Next
    	Else
    		clause = " location LIKE '%" & term & "%'"
    	End If
    	
    	sql = " WHERE " & clause
    	'sql = "SELECT * FROM location WHERE" & clause
    	'Response.Write sql
    End If
    %>
    It's only a quick basic version though.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And:

    Classic ASP Design Tips - Search For Keywords on Multiple Fields
    http://www.bullschmidt.com/devtip-se...iplefields.asp
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •