I have the following code that works very well, the problem is that of i search for say rap it returns back results that contain the words telegraph, grapfruit etc, how can i get it to just return results that have the word rap in the search string anywhere??
- <%
-
Dim strSearch, myarray, strSQL, strSQLExtra
-
If Not Request.Form("search") = "" Then
-
session("search") = Request.Form("search")
-
session("choice") = Request.Form("choice")
-
session("queryterm") = session("queryterm")+" "+Request.Form("search")
-
End If
-
-
'Loop is now in a function, so that we can feed it each field name.
-
Function addparams(fieldname,wordArray)
-
Dim tmp
-
tmp = ""
-
For each item in wordArray
-
tmp = tmp & " (" & fieldname & " Like '%" & item & "%') " & session("choice") & " "
-
next
-
tmp = left(tmp, len(tmp)-4) ' Chops off the last "AND "
-
addparams = tmp
-
End Function
-
-
'Build the word array
-
myarray = split(session("search"), " ")
-
-
'Build the SQL
-
strSQL = "SELECT * FROM mp3 INNER JOIN celebs ON mp3.celebid = celebs.idnumber WHERE ("
-
-
strSQL = strSQL & addparams("filename", myarray) ' change field one!
-
-
strSQL = strSQL & ") OR ("
-
-
strSQL = strSQL & addparams("mp3type", myarray) ' change field two!
-
-
strSQL = strSQL & ")order by surname, firstname, filename;"
-
session("sqlset") = strSQL
-
-
%>