<% 'Make the browser not cache this page: Response.Expires = 0 getConnection() 'Read parameters into a query string: strQuery = Request.Form & "&" & Request.QueryString if instr(strQuery,"page=")>0 then 'we were passed a page - hack it off. strQuery = left(strQuery,instr(strQuery,"page=")-1) end if while left(strQuery,1)= "&" strQuery = right(strQuery,len(strQuery)-1) wend while right(strQuery,1) = "&" strQuery = left(strQuery,len(strQuery)-1) wend 'Let's read the parameters passed and build an SQL statement: strWhere = "" if Request("resKeyword") <> "" then if instr(Request("resKeyword"),"'") > 0 or instr(Request("resKeyword"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if strWhere = "(ResTitle Like '%" & Request("resKeyword") & "%' OR Description Like '%" & Request("resKeyword") & "%' OR ResAuthor Like '%" & Request("resKeyword") & "%' OR ResPublisher Like '%" & Request("resKeyword") & "%' OR ResVendor Like '%" & Request("resKeyword") & "%' OR Subject Like '%" & Request("resKeyword") & "%') " end if if Request("resCode") <> "" then if instr(Request("resCode"),"'") > 0 or instr(Request("resCode"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resCode='" & Request("resCode") & "'" end if if Request("resCodeStart") <> "" then if instr(Request("resCodeStart"),"'") > 0 or instr(Request("resCodeStart"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resCode Like '" & Request("resCodeStart") & "%'" end if if Request("resTitle") <> "" then if instr(Request("resTitle"),"'") > 0 or instr(Request("resTitle"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "ResTitle Like '%" & Request("resTitle") & "%'" end if if Request("resType") <> "" then if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "tblResources.resCodePrefix='" & Request("resType") & "'" end if if Request("resHeading") <> "" then if strWhere <> "" then strWhere = strWhere & " AND " if left(Request("resHeading"),1)="H" then 'We have a heading strWhere = strWhere & "headID=" & right(Request("resHeading"),len(Request("resHeading"))-1) else 'We have a subheading strWhere = strWhere & "headSubID=" & right(Request("resHeading"),len(Request("resHeading"))-1) end if end if if Request("resDesc") <> "" then if instr(Request("resDesc"),"'") > 0 or instr(Request("resDesc"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "Description Like '%" & Request("resDesc") & "%'" end if if Request("resAuthor") <> "" then if instr(Request("resAuthor"),"'") > 0 or instr(Request("resAuthor"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resAuthor Like '%" & Request("resAuthor") & "%'" end if if Request("resPub") <> "" then if instr(Request("resPub"),"'") > 0 or instr(Request("resPub"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resPublisher Like '%" & Request("resPub") & "%'" end if if Request("resVendor") <> "" then if instr(Request("resVendor"),"'") > 0 or instr(Request("resVendor"),"""") > 0 then 'No quotes allowed: Session("fatal_error") = "Please do not enter quotes in your search fields" Response.Redirect "error.asp" end if if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resVendor Like '%" & Request("resVendor") & "%'" end if if Request("resAge") <> "" then if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resAge" & Request("resAge") & "=TRUE" end if if Request("resIsParent") <> "" then if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "resIsParent=" & Request("resIsParent") end if if Request("resSubject") <> "" or Request("resKeyword") <> "" then 'We have a subject to search on: if Request("resSubject") <> "" then if strWhere <> "" then strWhere = strWhere & " AND " strWhere = strWhere & "Subject='" & Request("resSubject") & "'" end if sql = "SELECT DISTINCT tblResources.*, tblResCodePrefixes.FullName, tblResCodePrefixes.LengthUnits FROM (tblResources INNER JOIN (tblSubjects INNER JOIN [tblResources-Subjects] ON tblSubjects.SubjectID = [tblResources-Subjects].SubjectID) ON tblResources.ResID = [tblResources-Subjects].ResID) INNER JOIN tblResCodePrefixes ON tblResources.ResCodePrefix = tblResCodePrefixes.ResCodePrefix" if strWhere <>"" then sql = sql & " WHERE " & strWhere end if else 'No subject: sql = "SELECT tblResources.*, tblResCodePrefixes.FullName, tblResCodePrefixes.LengthUnits FROM tblResources INNER JOIN tblResCodePrefixes ON tblResources.ResCodePrefix = tblResCodePrefixes.ResCodePrefix" if strWhere <>"" then sql = sql & " WHERE " & strWhere end if end if if Request("resSort") <> "" then sql = sql & " ORDER BY " & Request("resSort") end if sql2 = sql Set cmdTemp = Server.CreateObject("ADODB.Command") Set rsRes = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = sql cmdTemp.CommandType = 1 Set cmdTemp.ActiveConnection = cn rsRes.Open cmdTemp, , 1, 1 if rsRes.eof and rsRes.bof then 'No resources match: Session("fatal_error") = "Sorry, no matches for your search were found.

Try a new search

" Response.Redirect "error.asp" end if rsRes.movelast rsRes.movefirst countOfResults = rsRes.recordCount '**************************************************** ' What resources to display? Need page, # res/page '**************************************************** if Request("numResults")="" then numResults = 20 'default else numResults = Request("numResults") end if if Request("page")="" then curPage = 1 'default else curPage = Request("page") end if if (curPage - 1) * numResults + 1 > countOfResults then 'We've asked for a page that doesn't exist! curPage = int(countOfResults/numResults) if int(countOfResults/numResults) <> (countOfResults/numResults) then curPage = curPage + 1 end if end if resStart = 1 + (curPage-1) * numResults resEnd = curPage * numResults if resEnd > countOfResults then resEnd = countOfResults end if 'Skip the first x resources: rsRes.Move((curPage-1) * numResults) %> <%if (Request("detail")<>"Y") and (countOfResults <> 1) then 'We do normal:%> Resource Catalog Search Results

Resource Catalog Search Results

Click on a ResCode to view details for that resource:

<% if resStart > 1 or resEnd < countOfResults then 'We have at least another page: if curPage > 1 then 'Display previous page: Response.Write "" Response.Write "Previous  " else Response.Write "Previous  " end if if resEnd < countOfResults then 'We have a next page: Response.Write "" Response.Write "Next" else Response.Write "Next" end if else Response.Write "All results displayed." end if %> New Search Back to previous page View Cart
<%for n = resStart to resEnd%> <% rsRes.movenext next%>
<%if countOfResults<>1 then Response.Write resStart & "-" & resEnd & " of " & countOfResults & " resources displayed" else Response.Write countOfResults & " resource found and displayed." end if%>  
ResCode Type Title Author
&detail=Y"><%=rsRes("resCode")%>  <%=rsRes("ResCodePrefix")%>  <%=rsRes("resTitle")%>  <% 'Write resAuthor column: if rsRes("resAuthor")<>"" then Response.Write "" & rsRes("ResAuthor") & "" else Response.Write " " end if%>  
<% if resStart > 1 or resEnd < countOfResults then 'We have at least another page: if curPage > 1 then 'Display previous page: Response.Write "" Response.Write "Previous  " else Response.Write "Previous  " end if if resEnd < countOfResults then 'We have a next page: Response.Write "" Response.Write "Next" else Response.Write "Next" end if else Response.Write "All results displayed." end if %> New Search Back to previous page View Cart
<%else '(Request("detail")<>"Y") 'Show details: %> Resource Catalog Detailed Results

Resource Catalog Detailed Results

<%if countOfResults<>1 then Response.Write resStart & "-" & resEnd & " of " & countOfResults & " resources displayed" else Response.Write countOfResults & " resource found and displayed." end if%>
<%for n = resStart to resEnd%> <%if rsRes("ResParentID")>0 then%> <%end if%> <%if rsRes("ResAuthor")<>"" then%> <%end if%> <%if rsRes("ResPublisher")<>"" then%> <%end if%> <%if rsRes("ResPubYr")<>"" then%> <%end if%> <%if rsRes("ResVendor")<>"" then%> <%end if%> <%if rsRes("ResLength")>0 then%> <%end if%> <%if rsRes("headID")<>"" then%> <%end if%> <%if rsRes("ResLocation")<>"" then%> <%end if%> <%if rsRes("ResISBN")<>"" then%> <%end if%> <%if rsRes("Description")<>"" then%> <%end if%>
RESOURCE: (&detail=Y"><%=rsRes("ResCode")%>) <%=rsRes("ResTitle")%>     
SERIES: <% sql = "SELECT * FROM tblResources WHERE ResID=" & rsRes("ResParentID") set rsParent = cn.execute(sql) if not rsParent.eof then Response.Write "(" Response.Write "" & rsParent("ResCode") & ") " Response.Write rsParent("resTitle") end if %>
AUTHOR: "><%=rsRes("ResAuthor")%>
PUBLISHER: <%=rsRes("ResPublisher")%>
PUB YR: <%=rsRes("ResPubYr")%>
VENDOR: <%=rsRes("ResVendor")%>
LENGTH: <%=rsRes("ResLength") & " " & rsRes("LengthUnits")%>
HEADING: <% sql = "SELECT tblResources.ResID, tblHeadings.headKey, tblHeadingSub.headSubKey, tblHeadings.heading, tblHeadingSub.headSub FROM tblHeadingSub RIGHT JOIN (tblHeadings RIGHT JOIN tblResources ON tblHeadings.headID = tblResources.headID) ON tblHeadingSub.headSubID = tblResources.headSubID WHERE (((tblResources.ResID)=" & cstr(rsRes("ResID")) & ") AND ((tblHeadings.heading) Is Not Null))" set rsHead = cn.Execute(sql) if not rsHead.eof then if not isnull(rsHead("headSub")) then Response.Write rsHead("headKey") & rsHead("headSubKey") & " - " & rsHead("heading") & " / " & rsHead("headSub") else Response.Write rsHead("headKey") & " - " & rsHead("heading") end if end if %>
SUBJECT: <% sql = "SELECT tblSubjects.Subject FROM tblSubjects INNER JOIN [tblResources-Subjects] ON tblSubjects.SubjectID = [tblResources-Subjects].SubjectID WHERE [tblResources-Subjects].ResID=" & cstr(rsRes("ResID")) & " AND Subject<>'General' ORDER BY Subject" set rsSubj = cn.Execute(sql) t=false while not rsSubj.eof if not t then t = true else Response.Write ", " end if Response.Write rsSubj("Subject") rsSubj.Movenext wend %>
LOCATION: <%=rsRes("ResLocation")%>
ISBN/ISSN: <%=rsRes("ResISBN")%>
DESCRIPTION: <%=rsRes("Description")%>
<% sql = "SELECT * FROM tblVersion" set rsPrefs= cn.Execute(sql) %>
AGE GROUPS: " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr1")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr2")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr3")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr4")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr5")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr6")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr7")%> " href="agegrps.asp"><%=rsPrefs("ResAgeAbbr8")%>
  <%if rsRes("ResAge1") then Response.Write "X"%> <%if rsRes("ResAge2") then Response.Write "X"%> <%if rsRes("ResAge3") then Response.Write "X"%> <%if rsRes("ResAge4") then Response.Write "X"%> <%if rsRes("ResAge5") then Response.Write "X"%> <%if rsRes("ResAge6") then Response.Write "X"%> <%if rsRes("ResAge7") then Response.Write "X"%> <%if rsRes("ResAge8") then Response.Write "X"%>
<% if rsRes("ResIsParent")<>0 then 'We are a parent, so list the children: Response.Write "Resources in this series:" sql = "SELECT * FROM tblResources WHERE ResParentID=" & rsRes("ResID") & " ORDER BY ResParentSeq" Set rsChild = cn.Execute(sql) while not rsChild.EOF Response.Write "
(" Response.Write "" & rsChild("ResCode") & ") " & rsChild("ResTitle") rsChild.movenext wend end if %>
" name="ResID">

<% rsRes.MoveNext Next%>
<% if resStart > 1 or resEnd < countOfResults then 'We have at least another page: if curPage > 1 then 'Display previous page: Response.Write "" Response.Write "Previous  " else Response.Write "Previous  " end if if resEnd < countOfResults then 'We have a next page: Response.Write "" Response.Write "Next" else Response.Write "Next" end if else Response.Write "All results displayed." end if %> New Search Back to previous page View Cart

<%end if%>