Forums

ASP

This topic is locked

AND / OR use in search page

Posted 14 Apr 2006 21:22:47
1
has voted
14 Apr 2006 21:22:47 Wim Conix posted:
Hello,

I have a search page where you can fill in keywords. This results in a result page with a "LIKE %MMColparam% WHERE clause.
Is it possible to give more than one keyword in the search textfield, separated with AND / OR ?
What's the exact syntax for this. I tried several things but nothing seems to work so far. I'm simply getting no results no more when more than one keyword is given.
What I'm I forgetting or doing wrong ??

Any help appreciated !

Thanks,

Wim

Replies

Replied 14 Apr 2006 22:15:18
14 Apr 2006 22:15:18 micah santos replied:
I think it's possible by filtering your keywords first.
But they should be entered following by the comma.

E.g.

Search = name, gender, location, language

Here's how it's gonna work:

<%

// Query Procedure

Sub SearchInput()

// Use this syntax for searching records
// Set rsSearch = ObjConn.Execute("SELECT * FROM TABLE WHERE fieldName LIKE '%" & Queryword & "%' OR TABLE LIKE '%" & Queryword & "%' ORDER BY id DESC"
// Then, displays all found records here


// Response.write to test if keywords are separated from each other by removing commas in between

response.write Queryword & "<br>"

End Sub


// Variables

Dim strSearch

strSearch = Request.Form("search"


// Filter the search keywords by removing commas

QueryWordArray = Split(strSearch, ","
QueryWord = ""

For QueryWordNo=0 To UBound(QueryWordArray)

If instr(strSearch, QueryWordArray(QueryWordNo)) > 0 Then

QueryWord = QueryWordArray(QueryWordNo)

// Then call the procedure to search each word
Call SearchInput

End If

Next

%>
Replied 14 Apr 2006 22:23:22
14 Apr 2006 22:23:22 Wim Conix replied:
Thanks Micah,

I'm gonna try this directly and let you know the result...

Kind regards,

Wim
Replied 14 Apr 2006 23:02:01
14 Apr 2006 23:02:01 micah santos replied:
ok. good luck!

Reply to this topic