| | |
|
Active Server Pages what is asp programming how to sample asp example code scripts software asp forum mail sessions applications global.asa CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Search Engine Problem |
From: |
lukas |
Date: |
5/4/1999 1:02:22 PM |
IP: |
131.130.232.62 |
I created a little search engine that allows to enter in a query form +, - and or ....
My current problem is that with my script now it searchs only through one column of my database called "employees". The script for that is:
if Request.form("DaInBox") <> "" then
query = query & combine
Call parse ("Title", Request.Form("DaInBox"))
combine = " AND "
end if
The database contoins one table called employees with the columns Title, Description,Email
So how can i change the code that it allows me to search through all this fields.
Heres the whole code:
<%
sub parse(field, s) query = query & combine & "("
' if it begins and ends with a quote
' use Mid to cut out what is between the quotes
if Left(s,1) = """" and Right(s,1) = """" then
query = query & field & " LIKE '%" _
& Mid(s, 2, Len(s)-2) & "%'"
' or if it has a plus (+) in it
elseif InStr(s,"+") > 0 then
wordList = Split(s, "+")
for word = 0 to UBound(wordList)
query = query & field & " LIKE '%" & wordList(word) & "%'"
if word < UBound(wordList) then
query = query & " AND "
end if
next
' or if it starts with a minus (-)
elseif Left(s,1) = "-" then
query = query & field & " NOT LIKE '%" _
& Right(s, Len(s)-1) & "%'"
' otherwise split on spaces
else
wordList = Split(s)
for word = 0 to UBound(wordList)
query = query & field & " LIKE '%" & wordList(word) & "%'"
if word < UBound(wordList) then
query = query & " OR "
end if
next
end if
query = query & ")"
end sub
'Here starts the code as u can see it can only go through the Title column and not of the rest of it, but i dont know what i have to change.
'DaInBox=The SearchForm on a html Site
if Request.form("DaInBox") <> "" then
query = query & combine
Call parse ("Title", Request.Form("DaInBox"))
combine = " AND "
end if
' now build the full query and run it
query = "SELECT * FROM employees" _
& " WHERE " & query & " ORDER BY Title"
Set rs = db.Execute(query,&H0001) %>
thanks for helping
lukas
|
|
|

|
|
|
|