codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Common language searching....  Archive Import (James King) at 11:30 on Tuesday, July 22, 2003
 

This is probably really simple, but i`m having a no dice kinda week...

<%
Dim rsResults__MMColParam
rsResults__MMColParam = "1"
If (Request.Form("data") <> "") Then
rsResults__MMColParam = Request.Form("data")
End If
%>

What I want it to do is seperate the words coming from DATA into single words and apply each word to the recordset query, so that when it gets to..

SELECT * FROM faq WHERE question LIKE `%" + Replace(rsResults__MMColParam, "`", "``") + "%` ORDER BY ranking DESC"

it tests each (single) word from the request.form("data") against the question collumn in my database.

Thanks in advance for any help.

James



  Re: Common language searching....  Troy Wolf at 16:25 on Monday, July 28, 2003
 

1. Break the string into an array of single words. The VBScript Split() function defaults to splitting strings on single spaces.

aryX = Split(rsResults__MMColParam)

2. Next, build the sql statement. The Split() function will create an array even if there is only one item in the array. (index 0). Since you are first making sure the variable contains a value, we can be sure that we will end up with an array. Otherwise, you`d first want to test to make sure you have an array to work with (IsArray() function).

sql = "select *" & _
" from faq" & _
" where (question like `%" & aryX(0) & "%`"
aryLen = UBound(aryX)
if aryLen > 0 then
for i = 1 to UBound(aryX)
sql = sql & _
" or question like `%" & aryX(i) & "%`"
next
end if
sql = sql & ")"
End If
%>

The sql statement produced by this code will find all faqs where the question contains a match to at least one of the conditions. If you wanted it to match ALL the words, then change the ORs to ANDs. Don`t be surprised if you copy & paste this and get an error or two. I average 1 error for every 2 lines of code I write!
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Common language searching....  Elain at 08:04 on Friday, November 19, 2010
 

I don't think the question is simple, instead it is difficult!
----------------------------------------------
flash banner|logo maker|flash menu|








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  ASP.NET- is it possible to Restrict class
•  Re: File Formats
•  Re: very simple question
•  Re: title
•  Re: problem with eval function, please help me!
•  Re: I would like to put a column in an excel spreadsheet that reads +10/-10
•  Re: Common language searching....
•  The Internet in a Box-Widernet Project
•  Re: hi


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010