Search Our Photo Archives

<% Dim strSearchTerm strSearchTerm = Request.QueryString("searchterm") If (strSearchTerm = "") Then Response.Write "Please enter a search term in the box." Else Dim countSQL Dim SQL Dim fromWhere fromWhere = "FROM tblMain " &_ "WHERE ((tblMain.imagefile) IS NOT NULL) " &_ "AND ((((tblMain.caption) LIKE ""%" & strSearchTerm & "%"")) OR (((tblMain.collection) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.condition) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.credit) Like ""%" & strSearchTerm & "%"")) " &_ "OR (((tblMain.objname) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.phtgrapher) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.place) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.studio) Like ""%" & strSearchTerm & "%"")) " &_ "OR (((tblMain.title) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.descrip_) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.notes_) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.people_) Like ""%" & strSearchTerm & "%"")) " &_ "OR (((tblMain.sterms_) Like ""%" & strSearchTerm & "%"")) OR (((tblMain.subjects_) Like ""%" & strSearchTerm & "%"")))" 'response.write fromWhere countSQL = "SELECT Count(*) AS recordcount " & fromWhere & ";" SQL = "SELECT tblMain.ID, tblMain.descrip_, tblMain.imagefile " & fromWhere & " ORDER BY tblMain.descrip_;" ' Get the number of records ' If records found, display them Dim countRS Set countRS = Server.CreateObject("ADODB.Recordset") countRS.Open countSQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("\database\bhs_photo.mdb") intCount = countRS("recordcount") countRS.Close Set countRS = Nothing If intCount = 0 Then Response.Write "No photos found with the search term """ & strSearchTerm & """. Please try again." Else Response.Write "" & intCount & " photos found with the search term """ & strSearchTerm & """.

" & vbcrlf Response.Write "" & vbcrlf Dim CurrPage If IsEmpty(Request.QueryString("PageNo")) Then CurrPage = 1 Else CurrPage = cint(request.querystring("PageNo")) End If ' Get the records, display them, and create the next/previous navigation ' Thanks to dhtmlgod at http://www.sitepointforums.com/archive/index/t-17293 Dim pageRS Set pageRS = Server.CreateObject("ADODB.Recordset") pageRS.CursorLocation = 3 pageRS.Open SQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("\database\bhs_photo.mdb") pageRS.PageSize = 10 ' How many records per page you want pageRS.AbsolutePage = CurrPage DO UNTIL pageRS.AbsolutePage <> CurrPage OR pageRS.EOF Dim strID Dim strDescrip strID = pageRs("ID") strDescrip = Left(pageRs("descrip_"),100) & "..." Response.Write "" & strDescrip & "" Response.Write "

" pageRS.MoveNext Loop ' These functions set up the next/previous navigation function getNext10(num) pageLen = len(num) if pageLen = 1 then next10 = 10 elseif pageLen = 2 then pageRem = 10 pageTen = right(num, 1) next10 = num + pageRem - pageTen elseif pageLen > 2 then pageRem = 10 pageTen = right(num, 1) next10 = num + pageRem - pageTen end if getNext10 = next10 end function function getPrev10(num) pageLen = len(num) if pageLen = 1 then prev10 = 1 elseif pageLen = 2 then firstDig = left(num, 1) secondDig = right(num, 1) prev10 = num - secondDig - 10 elseif pageLen > 2 then firstDig = right(num, 2) secondDig = right(num, 1) prev10 = num - secondDig - 10 end if if prev10 = 0 then prev10 = 1 end if getPrev10 = prev10 end function RSPrevPage = CurrPage -1 RSNextPage = CurrPage + 1 next10 = getNext10(currPage) prev10 = getPrev10(currPage) if Next10 > pageRS.PageCount then next10 = pageRS.PageCount end if if prev10 = 1 AND next10 - 1 < 10 then start = 1 else start = Next10 - 10 if right(start, 1) > 0 then start = replace(start, right(start, 1), "0") start = start + 10 end if end if if pageRS.PageCount > 1 then if next10 > 10 then response.write("

<< ") end if if not RSPrevPage = 0 then response.write("< ") end if for P = start to Next10 if not P = CurrPage then response.write("" & P & " ") else response.write(" " & P & " ") end if Next if not RSNextPage > pageRS.PageCount then response.write("> ") end if if not Next10 = pageRS.PageCount then response.write(" >>") end if end if Response.Write "" pageRS.Close Set pageRS = Nothing End If ' End If/Then/Else statement after number of records test End If ' End searchTerm check If/Then/Else statement %>