Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Search

Status
Not open for further replies.
Nov 15, 2002
13
CA
Hi guys,

I have two parts to implement in my ASP. First of all I have a search page where there are 10 text boxes. In a nutshell I want to enable to user to search from any one of these text fields. So its a OR clause in the SQL part. The more fields the user fills in, the more accurate the results are going to be.

What I am having trouble is with the implementation part. Any ideas to get me started would be very welcome.

Thanks.
 
Loop through your input boxes in your asp code.

Code:
dim sSQL
sSQL = "Select * From mytable Where "
dim sWhereClause
If len(request("box1")) > 0 then
  sWhereClause = "dbField = " & request("box1")
end if

if len(request("box2")) > 0 then
 if len(sWhereClause) > 0 then
   sWhereClause = sWhereClause & " OR dbField = " & request("box2")
 else
   sWhereClause = "dbField = " & request("box2")
 end if
... the rest of your text boxes here

dim sFullSQL
sFullSQL = sSQL & sWhereClause


end if
Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top