Search Engine

Results 1 to 6 of 6

Thread: Search Engine

  1. #1
    Join Date
    Dec 1969
    Posts
    37

    Default Search Engine

    Hello,<BR><BR>I am trying to create a search engine for a site that queries the database and returns results. I have a form created that you can enter the search term and category to search, but it doesn&#039;t seem to search on any words past the first one. Can anyone help?<BR><BR>I have created an array for the search term and split the array at the spaces. How do I get the sql search to work?<BR><BR>Thanks<BR>Josh

  2. #2
    Join Date
    Dec 1969
    Posts
    85

    Default RE: Search Engine

    speaking of search engines, there is a site called Google (specifically www.google.com). Try it and make your search "ASP vs PHP" (use the quotation marks) and see what you get. I got over 1900 hits. <BR><BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    3,195

    Default Well what is the problem?

    Are you not getting all your passed values from the form? Or is your search not working (i.e. - you need help writing your SQL)?<BR><BR>You need to explain your problem a little better and provide examples.<BR><BR>When you say "it doesn&#039;t seem to search on any words past the first one" doesn&#039;t really help us ; )<BR><BR>Good luck<BR>Pete<BR><BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    37

    Default RE: Well what is the problem?

    Sorry,<BR><BR>Here is the code for the search form<BR><BR>The search is not working. I think the values are being passed.<BR><BR>&#060;------------------------------&#062;<BR>&#060;form action="search_results.asp" method="post"&#062;<BR>&#060;div align="center"&#062;Search for: &#060;input type="text" name="search"&#062;<BR>&#060;P&#062;<BR>In the category:<BR><BR>&#060;/div&#062;<BR>&#060;Table&#062;<BR>&#060;tr&#062;<B R>&#060;td&#062;&#060;input type="radio" name="table" value="Ant_Info"&#062;Antiques&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Auc_Info"&#062;Auctions&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Autos_Info"&#062;Autos/Trucks&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Collect_Info"&#062;Collectables&#060;/td&#062;<BR>&#060;/tr&#062;<BR>&#060;tr&#062;<BR>&#060;td&#062;&#060; input type="radio" name="table" value="FarEqu_Info"&#062;Farm Equipment&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="HomeInfo"&#062;Homes&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="HouIte_Info"&#062;Household Items&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Land_Info"&#062;Land/Acreage&#060;/td&#062;<BR>&#060;/tr&#062;<BR>&#060;tr&#062;<BR>&#060;td&#062;&#060; input type="radio" name="table" value="Misc_Info"&#062;Miscellaneous&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="RecEqu_Info"&#062;Recreational Equipment&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Rent_Info"&#062;Rentals&#060;/td&#062;<BR>&#060;td&#062;&#060;input type="radio" name="table" value="Serv_Info"&#062;Services&#060;/td&#062;<BR>&#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;P&#062;<BR>&#060;div align="center"&#062;&#060;input type="submit" name="Submit" value="Search for Items"&#062;&#060;/div&#062;<BR>&#060;/form&#062;<BR><BR>&#060;---------------------------------&#062;<BR>And here is the code for the results page<BR><BR>&#060;--------------------------------&#062;<BR><BR>&#060;%<BR>table = request.form("table")<BR>search = request.form("search")<BR><BR>if table &#060;&#062; "" then<BR>if table = "Autos_Info" then<BR>tablename = "autos"<BR>idname = "auto"<BR><BR>mystring = search<BR>myarray =split(mystring)<BR>Count = UBOUND(myarray)<BR>for a = 0 to count<BR>search1 = myarray(a)<BR><BR>set dReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from "&table&" WHERE title like &#039;%"&search1&"%&#039; or description like &#039;%"&search1&"%&#039; or make like &#039;%"&search1&"%&#039; or model like &#039;%"&search1&"%&#039; or year like &#039;%"&search1&"%&#039;"<BR> dReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set rs = dReunion.execute (sSQL)<BR>next<BR>&#039;else if table = "HomeInfo" then<BR>&#039;tablename = "more"<BR>&#039;idname = "Home"<BR><BR>&#039;set dReunion = server.CreateObject ("adodb.connection")<BR>&#039; sSQL = "SELECT * from "&table&" WHERE notes like &#039;%"&search&"%&#039; or housetype like &#039;%"&search&"%&#039; or yearbuilt like &#039;%"&search&"%&#039; or city like &#039;%"&search&"%&#039;"<BR>&#039; dReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR>&#03 9; set rs = dReunion.execute (sSQL)<BR><BR>else<BR>mystring = search<BR>myarray =split(mystring)<BR>Count = UBOUND(myarray)<BR>for a = 0 to count<BR>search1 = myarray(a)<BR>set dReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from "&table&" WHERE title like &#039;%"&search1&"%&#039; or description like &#039;%"&search1&"%&#039;"<BR> dReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set rs = dReunion.execute (sSQL)<BR>next<BR>if table = "Ant_Info" then<BR>tablename = "antiques"<BR>idname = "ant"<BR>end if<BR>if table = "Auc_Info" then<BR>tablename = "auctions"<BR>idname = "auc"<BR>end if<BR>if table = "Collect_Info" then<BR>tablename = "collectables"<BR>idname = "collect"<BR>end if<BR>if table = "FarEqu_Info" then<BR>tablename = "farm"<BR>idname = "farm"<BR>end if<BR>if table = "HouIte_Info" then<BR>tablename = "household"<BR>idname = "household"<BR>end if<BR>if table = "Land_Info" then<BR>tablename = "land"<BR>idname = "land"<BR>end if<BR>if table = "Misc_Info" then<BR>tablename = "misc"<BR>idname = "misc"<BR>end if<BR>if table = "RecEqu_Info" then<BR>tablename = "rec"<BR>idname = "rec"<BR>end if<BR>if table = "Rent_Info" then<BR>tablename = "rent"<BR>idname = "rent"<BR>end if<BR>if table = "Serv_Info" then<BR>tablename = "service"<BR>idname = "service"<BR>end if<BR><BR>&#039;end if<BR>end if<BR>if rs.eof then<BR>response.write "No Results Returned!"<BR>else<BR>%&#062;<BR>&#060;table align="center" cellpadding="10" cellspacing="10" border="5"&#062;<BR>&#060;tr&#062;<BR>&#060;td&#06 2;Title:&#060;/td&#062;<BR>&#060;td&#062;Price:&#060;/td&#062;<BR>&#060;td&#062;More Information:&#060;/td&#062;<BR>&#060;/tr&#062;<BR><BR><BR>&#060;% <BR>end if<BR><BR>while not rs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &rs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & rs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(rs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>rs.movenext<BR>wend<BR><BR>else<BR>%& #062;<BR>&#060;table align="center" cellpadding="10" cellspacing="10" border="5"&#062;<BR>&#060;tr&#062;<BR>&#060;td&#06 2;Title:&#060;/td&#062;<BR>&#060;td&#062;Price:&#060;/td&#062;<BR>&#060;td&#062;More Information:&#060;/td&#062;<BR>&#060;/tr&#062;<BR><BR><BR>&#060;% <BR><BR>mystring = search<BR>myarray =split(mystring)<BR>Count = UBOUND(myarray)<BR>for a = 0 to count<BR>search1 = myarray(a)<BR>set AntReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Ant_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> AntReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set ms = AntReunion.execute (sSQL)<BR>next<BR> if not ms.eof then<BR> tablename = "antiques"<BR> idname = "ant"<BR> end if<BR><BR> while not ms.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &ms("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & ms("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(ms(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>ms.movenext<BR>wend<BR><BR>for b = 0 to count<BR>search1 = myarray(b)<BR>set AucReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Auc_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> AucReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set bs = AucReunion.execute (sSQL)<BR>next<BR> if not bs.eof then<BR> tablename = "auctions"<BR> idname = "auc"<BR> end if<BR><BR> while not bs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &bs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & bs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(bs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>bs.movenext<BR>wend<BR><BR>for c = 0 to count<BR>search1 = myarray(c)<BR>set AutoReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Autos_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039; or make like &#039;%"&search&"%&#039; or model like &#039;%"&search&"%&#039; or year like &#039;%"&search&"%&#039;"<BR> AutoReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set cs = AutoReunion.execute (sSQL)<BR>next<BR> if not cs.eof then<BR> tablename = "autos"<BR> idname = "auto"<BR> end if<BR> while not cs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &cs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & cs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(cs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>cs.movenext<BR>wend<BR><BR>for d = 0 to count<BR>search1 = myarray(d)<BR>set ColReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Collect_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> ColReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set ds = ColReunion.execute (sSQL)<BR>next<BR> if not ds.eof then<BR> tablename = "collectables"<BR> idname = "collect"<BR> end if<BR> while not ds.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &ds("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & ds("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(ds(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>ds.movenext<BR>wend<BR><BR>for e = 0 to count<BR>search1 = myarray(e)<BR>set FarReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from FarEqu_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> FarReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set es = FarReunion.execute (sSQL)<BR>next<BR> if not es.eof then<BR> tablename = "farm"<BR> idname = "farm"<BR> end if<BR> while not es.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &es("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & es("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(es(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>es.movenext<BR>wend<BR><BR>for f = 0 to count<BR>search1 = myarray(f)<BR>set HouReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from HouIte_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> HouReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set fs = HouReunion.execute (sSQL)<BR>next<BR> if not fs.eof then<BR> tablename = "household"<BR> idname = "household"<BR> end if<BR> while not fs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &fs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & fs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(fs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>fs.movenext<BR>wend<BR><BR>for g = 0 to count<BR>search1 = myarray(g)<BR>set LanReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Land_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> LanReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set gs = LanReunion.execute (sSQL)<BR>next<BR> if not gs.eof then<BR> tablename = "land"<BR> idname = "land"<BR> end if<BR> while not gs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &gs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & gs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(gs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>gs.movenext<BR>wend<BR><BR>for h = 0 to count<BR>search1 = myarray(h)<BR>set MisReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Misc_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> MisReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set hs = MisReunion.execute (sSQL)<BR>next<BR> if not hs.eof then<BR> tablename = "misc"<BR> idname = "misc"<BR> end if<BR> while not hs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &hs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & hs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(hs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>hs.movenext<BR>wend<BR><BR>for i = 0 to count<BR>search1 = myarray(i)<BR>set RecReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from RecEqu_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> RecReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set ls = RecReunion.execute (sSQL)<BR>next<BR> if not ls.eof then<BR> tablename = "rec"<BR> idname = "rec"<BR> end if<BR> while not ls.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &ls("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & ls("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(ls(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>ls.movenext<BR>wend<BR><BR>for j = 0 to count<BR>search1 = myarray(j)<BR>set RenReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Rent_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> RenReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set js = RenReunion.execute (sSQL)<BR>next<BR> if not js.eof then<BR> tablename = "rent"<BR> idname = "rent"<BR> end if<BR> while not js.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &js("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & js("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(js(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>js.movenext<BR>wend<BR><BR>for k = 0 to count<BR>search1 = myarray(k)<BR>set SerReunion = server.CreateObject ("adodb.connection")<BR> sSQL = "SELECT * from Serv_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR> SerReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set ks = SerReunion.execute (sSQL)<BR>next<BR> if not ks.eof then<BR> tablename = "service"<BR> idname = "service"<BR> end if<BR> while not ks.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &ks("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & ks("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(ks(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>ks.movenext<BR>wend<BR><BR>end if<BR><BR>&#060;----------------------------------------&#062;<BR>Hope that this helps.<BR><BR>Josh


  5. #5
    Join Date
    Dec 1969
    Posts
    480

    Default RE: Well what is the problem?

    In many of your sql statements you have search1 instead of search

  6. #6
    Join Date
    Dec 1969
    Posts
    3,195

    Default Oh where to start...

    I&#039;m trying to stop my headache from looking at that code ; )<BR><BR>Seriously though, before I even try to go any further I believe you are doing WAY too much work here. You could cut out a lot of this code by using subs or functions.<BR><BR>For example you don&#039;t have to repeat this code everytime:<BR><BR>for g = 0 to count<BR>search1 = myarray(g)<BR>set LanReunion = server.CreateObject ("adodb.connection")<BR>sSQL = "SELECT * from Land_Info WHERE title like &#039;%"&search&"%&#039; or description like &#039;%"&search&"%&#039;"<BR>LanReunion.Open "sysdsnHomesDirectInc","nemeth","stanwade"<BR> set gs = LanReunion.execute (sSQL)<BR>next<BR>if not gs.eof then<BR>tablename = "land"<BR>idname = "land"<BR>end if<BR>while not gs.eof<BR>response.write "&#060;tr&#062;&#060;td&#062;" &gs("title")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & gs("Price")&"&#060;/td&#062;"<BR>response.write "&#060;td&#062;&#060;a href=&#039;view"&tablename&"info.asp?"&idname&"Id= "&cstr(gs(0))&"&#039;&#062;Click Here&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>gs.movenext<BR>wend<BR><BR>Now you said you "think the values are being passed". Whenever someone says to me they think that tends to scare me. Do a little debugging and reponse.write some values out to the screen. In addition, try putting some response.write statements in strategic parts of your code so you KNOW whether it is being executed or not.<BR><BR>You have your work cut out for you here ; ) However, clean up the code a little and it will make your life a lot easier.<BR><BR>Good luck<BR>Pete<BR><BR><BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •