View Full Version : searching question
gilgalbiblewhee
05-17-2006, 09:12 PM
Let's say I write 5 words and I want a search made for a combination of 3 words (out of the 5) how do I code this?
worda or wordb or wordc (all the possible combinations)
Spudhead
05-18-2006, 01:06 PM
Err... what are you searching? A string? An array? A database?
degsy
05-18-2006, 04:17 PM
<%
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
%>
Here is some basic code for searching multiple terms. It just builds a simple SQL query.
It can be easily edited and improved on to suit.
gilgalbiblewhee
05-18-2006, 07:53 PM
Yes it's for a database. The textarea is named "keywordg". Does keywordg replace term?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.