PDA

View Full Version : Consolidate search functions into single form


sfguy
06-19-2003, 08:02 PM
I'm trying to consolidate my search functions into a single search field, where the user can choose to search whatever they want, based on which area they choose (just like Amazon.com, where the user can enter their search terms, then choose Books, Music, Videos, etc.).
Is there anyway to do this in ASP (or Javascript) that will choose the appropriate search script to redirect it to and use it????

thanks in advance!!!

raf
06-20-2003, 08:15 AM
Welcome here,

For such a searchengine, you best set up a database where you have this areas as an indexed variable in the table that holds your articles (option 1), or by spreading the articles over different tables (each table has all articles of one area) (option 2) --> depends on how many articles/area you've got.
Or you can mix the two --> some area's get a seperate table, others or store together in one table

You then just use the selected areas in the where claues (in option 1) or to set the table to search in. Something like


select case request.form("area")
case "book" 'in seperate table for books
sql="SELECT * FROM thetable WHERE keyword like 'bla'"
sql=replace(sql,"thetable",request.form("area")
case "videos" 'in maintable cause there aren't enoug video's to set up a seperate table
sql="SELECT * FROM specialarticles WHERE keyword like 'bla'" AND area=2"
...
case else
response.write("You haven't made a valid choice. Please go back etc etc")
response.end
end select


You see?

For real searche pages, on rather big tables, best set up a MySQL db and use the full text search feature which gives more flexability and better performance when searching on textvalues.