Main Menu:
*Home About Us Contact Us Customer Login Privacy and Security Policy Products Returns Search Shipping Policy Shopping Cart
Product Categories Select Box:
|
Search Us
<%@ LANGUAGE = "VBScript"
ENABLESESSIONSTATE = False %>
<%
Set cnDZ = Server.CreateObject("ADODB.Connection")
cnDZ.Open "DSN=asapstl" 'change this Microsoft Access System DSN to your own
'Begin global variables:
'On Error Resume Next
Const adOpenStatic = 3
Const adUseClient = 3
Const maxRecords = 200 'this is how many records can be called/returned at one time.
sorry = "
Sorry, nothing was found."
srch = Replace(Request.Form("srch"), " ", "%")
If srch = "" Then srch = "%"
searchBy = Request.Form("searchBy")
mypage = Request.Form("pgNum")
If Not IsNumeric(mypage) Then
mypage = 1
ElseIf mypage = "" Then
mypage = 1
Else mypage = Int(Request.Form("pgNum"))
End If
mode = Request.QueryString("mode")
specific = Request.QueryString("specific")
yr = Year(Now)
mnth = MonthName(Month(Now))
fc = " face=Verdana"
'End global variables.
'--Begin standard title and meta tags here:
Response.Write"Search Engine v2.5"
'--End standard title and meta tags.
Response.Write""
'--Begin template specific code:
'insert your own html tags and other markup here
'--End template specific code.
'----------------------- Begin Page Content here:
If mode = "" Then 'just show the default search page
'Response.Write pc 'you could also use a page content(pc) var here & get your search page from a db
Response.Write""&_
""&_
""
ElseIf mode = "results" Then 'show the search results page here
If searchBy = "" Then searchBy = "Products"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
'replace these table and field names with your own database table and field names:
If searchBy = "Products" Then sqlQry = "SELECT TOP "&maxRecords&" * FROM TABLENAME WHERE FIELD1 LIKE '%%%"&srch&"%%%' OR FIELD2 LIKE '%%%"&srch&"%%%' ORDER BY FIELD1, FIELD2 ASC;"
If searchBy = "Snippets" Then sqlQry = "SELECT TOP "&maxRecords&" * FROM TABLENAME WHERE FIELD1 LIKE '%%%"&srch&"%%%' OR FIELD2 LIKE '%%%"&srch&"%%%' ORDER BY FIELD1, FIELD2 ASC;"
If searchBy = "Support" Then sqlQry = "SELECT TOP "&maxRecords&" * FROM TABLENAME WHERE FIELD1 LIKE '%%%"&srch&"%%%' OR FIELD2 LIKE '%%%"&srch&"%%%' ORDER BY FIELD1, FIELD2 ASC;"
rs.Open sqlQry, cnDZ, adOpenStatic
If Not rs.EOF Then
rs.MoveFirst
rs.PageSize = 30
maxcount = CInt(rs.PageCount)
rs.AbsolutePage = mypage
howmanyrecs = 0
LinkCount = 0
If rs.recordcount = 1 Then showS = "" Else showS = "s"
If srch = "%" Then thesrch = "all" Else thesrch = Replace(srch, "%", " ")
Response.Write"Searching "&searchBy&" for """&thesrch&""" found "&rs.recordcount&" result"&showS&":"
If maxcount > 1 Then Response.Write" Page "&mypage&" of "&maxcount&""
Response.Write"
"
While Not rs.EOF And howmanyrecs < rs.pagesize
If LinkCount Mod 2 = 0 Then bgColor = " bgcolor=""#F3F3F3""" Else bgColor = ""
Response.Write""
If searchBy = "Products" Then
hilite1 = Replace(rs("FIELD1"), srch, ""&srch&"", 1, -1, 1)
hilite2 = Replace(rs("FIELD2"), srch, ""&srch&"", 1, -1, 1)
'display.asp just needs to be a standard asp page that displays one record.
'example: SELECT * FROM TABLE WHERE ID = "&specific&";
Response.Write""&hilite1&" "&hilite2&" | "
ElseIf searchBy = "Snippets" Then
'put the same code here to display a snippets sqlqry
ElseIf searchBy = "Support" Then
'put the same code here to display a support sqlqry
Else Response.Write sorry 'that is not a valid searchby
End If
Response.Write" "
rs.MoveNext
howmanyrecs = howmanyrecs + 1
LinkCount = LinkCount + 1
Wend
Response.Write" Care to try your search again..?"
If maxcount > 1 Then
If mypage + 1 > maxcount Then nextPg = 1 Else nextPg = mypage + 1
Response.Write""
End If
rs.Close
Else Response.Write sorry 'no records were found
End If
Set rs = Nothing
Else Response.Write sorry 'that is not a valid mode
End If
'----------------------- End Page Content.
'--Begin template specific code:
'insert your own html tags and other markup here
'--End template specific code.
%>
<% cnDZ.Close
Set cnDZ = Nothing %>
|