<%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
Response.Expires = 0
Dim conn, SQL, RS, searchItem, DBQ, myScript, queryCategory, sSelectedTable , sDoRunDatabase
%>
<%sDoRunDatabase = true%>
<%
Send "<form method=get action='"& myScript &"'>"
Send "<input type=text name=SEARCH value=Search>"
Send "<select name=SELECTOR onChange=self.location='mypage.asp?cat_id='+this.options[this.selectedIndex].value>"
send "<option>--</option>"
send "<option value=?search=%25>All</option>"
Send "<option value=1>Artist</option>"
Send "<option value=2>Painting</option>"
Send "</select>"
Send "<input type=submit name=submit value=submit></form>"
%>
<%
Select Case querycategory
Case "1"
sSelectedTable = "Artist"
Case "2"
sSelectedTable = "Painting"
Case "3"
sDoRunDatabase = false
End Select
%>
<%SearchItem = trim(request.querystring("SEARCH"))%>
<% IF len(searchItem) = 0 THEN
myScript = Request.ServerVariables("SCRIPT_NAME")
ELSE
Set conn = Server.CreateObject("ADODB.Connection")
DBQ = server.mappath("db1.mdb")
conn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBQ
SQL="SELECT Title,Painting,Image FROM table1"
SQL=SQL & " WHERE '"&sSelectedTable&"%' LIKE '%"&searchItem&"%' "
SQL=SQL & " ORDER BY Artist"
Set RS = conn.execute(SQL)
Send "<table cellpadding=2>"
WHILE not RS.eof
Send "<tr><td><img src =images/" & RS("Image") & " width=130 height=130></img></td>"
send "<td bgcolor=#D6DBEF width=470> <B><font face=Arial, Helvetica, sans-serif>" & RS ("Painting") & "</b>"
send "<br> " & RS ("Artist") & "</b>"
RS.MoveNext
Wend
Send "</table>"%>
<%RS.close : Set RS = Nothing : conn.close : Set conn = Nothing
End if %>
<%Sub send (html) : response.write html & vbCRLF : end sub %>