Click to See Complete Forum and Search --> : A problem with a search engine.


weee
11-18-2004, 12:30 PM
Hi There.

I built a serch engine but it seems like it doesn't work good:
It contains 3 different type of search. The problem accur whenever I choose everything else but the first one (visa). Then I'm getting n error. I think it's something in the IF's I wrote. Any idea how should I do it better?


visa = fixStr(request.form("visa"))
continent = fixStr(request.form("continent"))
gender = fixStr(request.form("gender"))

If visa <> "" Then
SQLvisa = " WHERE visa='" & visa & "'"
Else
SQLvisa = ""
End If

If continent <> "" Then
SQLcontinent = " AND continent='" & continent & "'"
If visa = "" Then
SQLcontinent = " WHERE continent='" & continent & "'"
End If
Else
SQLContinent = ""
End If

If gender <> "" Then
SQLgender= " AND gender='" & gender & "'"
If continent = "" Then
SQLgender = " WHERE gender='" & gender & "'"
End If
Else
SQLgender= ""
End If

SQL = "SELECT FirstName,LastName,email,PhoneNumber1,PhoneNumber2 FROM members" & SQLUSVisa & SQLgender & SQLContinent & " ORDER BY id"


Thanks!

buntine
11-19-2004, 06:50 PM
Its your SQL queries... SQLUSVisa and SQLVisa are different.

Print out your SQL query before you execute it and you should see your problem.

Regards.

weee
11-19-2004, 07:02 PM
I'll check it out. Thanks!