Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 7th, 2006, 05:00 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
Basic Search Engine using Dreamweaver

or "How to display content from a database depending on submitted text using Dreamweaver's inbuilt scripts".


This was created as a example for a user who wanted to display book data based on a search type and a search term.

The search types are Title, Author and Genre


It is very basic. It simply checks if the search term is in the chosen field in the database.

Dreamweaver Basic Search Engine
asp Code:
Original - asp Code
  1.  
  2. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  3. <%
  4. MM_dw_search_engine_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("search_engine.mdb")
  5. %>
  6. <%
  7. Dim search__SearchTerm
  8. search__SearchTerm = "-1"
  9. If (Request.Form("SearchTerm") <> "") Then
  10.   search__SearchTerm = Request.Form("SearchTerm")
  11. End If
  12. %>
  13. <%
  14. Dim search__SearchType
  15. search__SearchType = "Author"
  16. If (Request.Form("SearchType") <> "") Then
  17.   search__SearchType = Request.Form("SearchType")
  18. End If
  19. %>
  20. <%
  21. Dim search
  22. Dim search_numRows
  23.  
  24. Set search = Server.CreateObject("ADODB.Recordset")
  25. search.ActiveConnection = MM_dw_search_engine_STRING
  26. search.Source = "SELECT *  FROM Books  WHERE " + Replace(search__SearchType, "'", "''") + " LIKE '%" + Replace(search__SearchTerm, "'", "''") + "%'"
  27. search.CursorType = 0
  28. search.CursorLocation = 2
  29. search.LockType = 1
  30. search.Open()
  31.  
  32. search_numRows = 0
  33. %>
  34. <%
  35. Dim books
  36. Dim books_numRows
  37.  
  38. Set books = Server.CreateObject("ADODB.Recordset")
  39. books.ActiveConnection = MM_dw_search_engine_STRING
  40. books.Source = "SELECT * FROM Books"
  41. books.CursorType = 0
  42. books.CursorLocation = 2
  43. books.LockType = 1
  44. books.Open()
  45.  
  46. books_numRows = 0
  47. %>
  48. <%
  49. Dim Repeat1__numRows
  50. Dim Repeat1__index
  51.  
  52. Repeat1__numRows = -1
  53. Repeat1__index = 0
  54. search_numRows = search_numRows + Repeat1__numRows
  55. %>
  56. <%
  57. Dim Repeat2__numRows
  58. Dim Repeat2__index
  59.  
  60. Repeat2__numRows = 10
  61. Repeat2__index = 0
  62. books_numRows = books_numRows + Repeat2__numRows
  63. %>
  64. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  65. <html xmlns="http://www.w3.org/1999/xhtml">
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  68. <title>Search</title>
  69. </head>
  70.  
  71. <body>
  72. <form name="form1" id="form1" method="post" action="">
  73.   <p>Search Field
  74.     <select name="SearchType" id="SearchType">
  75.       <option value="Title">Title</option>
  76.       <option value="Author">Author</option>
  77.       <option value="Genre">Genre</option>
  78.     </select>
  79. </p>
  80.   <p>Search Term
  81.     <input name="SearchTerm" type="text" id="SearchTerm" />
  82. </p>
  83.   <p>
  84.     <input type="submit" name="Submit" value="Search" />
  85.   </p>
  86. </form>
  87. <hr />
  88. <p>&nbsp;</p>
  89.  
  90.  
  91.  
  92.  
  93. <% If Not search.EOF Or Not search.BOF Then %>
  94. <table border="1" cellpadding="0" cellspacing="2">
  95.   <tr>
  96.     <td>id</td>
  97.     <td>Title</td>
  98.     <td>Author</td>
  99.     <td>Genre</td>
  100.   </tr>
  101.   <% While ((Repeat1__numRows <> 0) AND (NOT search.EOF)) %>
  102.   <tr>
  103.     <td><%=(search.Fields.Item("id").Value)%></td>
  104.     <td><%=(search.Fields.Item("Title").Value)%></td>
  105.     <td><%=(search.Fields.Item("Author").Value)%></td>
  106.     <td><%=(search.Fields.Item("Genre").Value)%></td>
  107.   </tr>
  108.     <%
  109.   Repeat1__index=Repeat1__index+1
  110.   Repeat1__numRows=Repeat1__numRows-1
  111.   search.MoveNext()
  112. Wend
  113. %>
  114. </table>
  115. <% End If ' end Not search.EOF Or NOT search.BOF %>
  116.  
  117. <% If Request.Form("Submit") = "Search" And search.EOF And search.BOF Then %>
  118. No records found!
  119. <% End If ' end search.EOF And search.BOF %>
  120.  
  121. <p>&nbsp;</p>
  122. <hr />
  123. <p>&nbsp;</p>
  124. <p>All books</p>
  125. <table border="1" cellpadding="0" cellspacing="2">
  126.   <tr>
  127.     <td>id</td>
  128.     <td>Title</td>
  129.     <td>Author</td>
  130.     <td>Genre</td>
  131.   </tr>
  132.   <% While ((Repeat2__numRows <> 0) AND (NOT books.EOF)) %>
  133.   <tr>
  134.     <td><%=(books.Fields.Item("id").Value)%></td>
  135.     <td><%=(books.Fields.Item("Title").Value)%></td>
  136.     <td><%=(books.Fields.Item("Author").Value)%></td>
  137.     <td><%=(books.Fields.Item("Genre").Value)%></td>
  138.   </tr>
  139.   <%
  140.   Repeat2__index=Repeat2__index+1
  141.   Repeat2__numRows=Repeat2__numRows-1
  142.   books.MoveNext()
  143. Wend
  144. %>
  145. </table>
  146. </body>
  147. </html>
  148. <%
  149. search.Close()
  150. Set search = Nothing
  151. %>
  152. <%
  153. books.Close()
  154. Set books = Nothing
  155. %>


This is all done with the inbuilt Dreamweaver scripts. It does not search multiple terms. To do that you would have to incorporate your own scripts.



You can replace this
Code:
<%
MM_dw_search_engine_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("search_engine.mdb")
%>


With the Dreamweaver connection include
e.g.
Code:
<!--#include file="Connections/dw_search_engine.asp" -->
Attached Files
File Type: zip dw_search_engine.zip (8.3 KB, 438 views)
__________________
CyberTechHelp

Reply With Quote
  #2  
Old November 14th, 2006, 10:33 AM
EddieP EddieP is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 13 EddieP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 53 m 50 sec
Reputation Power: 0
Hey...
I created a search engine, more or less like this one, and it searches only a specific word in my DB field. What i want to know:what do i have to do that allows this search engine to search the words in a random way...!

Reply With Quote
  #3  
Old November 15th, 2006, 05:11 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
As stated, this example is very basic. It will only search the exact phrase posted.

If you want to search for individual words then you need to split the search terms and build a query.

http://forums.aspfree.com/asp-devel...&highlight=term

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Basic Search Engine using Dreamweaver


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |