|
I'm doin (tryin to anyway) a simple gallery (asp/access) for a smaller website. I'd like it to be thumb pages linking to the full size images with an added search function and a paging function. (1,2,3,4>>)
The piece of code below can show u what I mean, it just needs the paging function. My problem is that I'm not good enuff at asp to incorporate a paging function. So I was wondering if anyone's seen a script like that somewhere, or if maybe someone had a script they wouldn't mind sharing..?
TIA
Regards, OMG
<% OPTION EXPLICIT %> <!-- #include file="connect.asp" --> <html><head><title>Photoalbum</title> </head><body>
<% dim strAction strAction=request("action")
Main
select case strAction case "search" Search request("searchstr"), 0 case "category" Search request("searchstr"), 1 case "show" ShowImage request("image") end select
' ------------------------------------- ' Functions ' -------------------------------------
sub Main %> <h1>Photoalbum</h1> <p>Search: <form action="photoalbum.asp?action=search" method="post"> <input type="text" name="searchstr"> <input type="submit" value="Søg"></form></p> <p>Or choose from category:<br> <% dim strSQL, objRS, arrCategories, i strSQL = "SELECT DISTINCT category FROM PhotoAlbum " & _ "ORDER BY category" strSQL = "SELECT category, count(category) as numcat FROM PhotoAlbum " & _ "GROUP BY category"
set objRS = server.createobject("ADODB.Recordset") objRS.open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText if not objRS.EOF then arrCategories = objRS.GetRows end if objRS.close set objRS = nothing if isArray(arrCategories) then for i = 0 to ubound(arrCategories,2) response.write _ " <a href=""photoalbum.asp?action=category&searchstr=" & _ server.urlencode(arrCategories(0,i)) & """>" & _ arrCategories(0,i) & "(" & arrCategories(1,i) & ")" & "</a> " next end if %> <hr></p><% end sub
sub Search (strS, intType) dim strSQL, objRS if intType = 0 then strSQL = "SELECT title, imagename FROM PhotoAlbum " & _ "WHERE title + description + words LIKE '%" & strS & "%'" end if if intType = 1 then strSQL = "SELECT title, imagename FROM PhotoAlbum " & _ "WHERE category = '" & strS & "'" end if set objRS = server.createobject("ADODB.Recordset") with objRS .open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText while not .EOF response.write _ "<p><a href=""photoalbum.asp?action=show&image=" & _ server.urlencode(.Fields("imagename")) & """>" & _ "<img src=""/thumbs/" & .Fields("imagename") & """ border=0>" & _ "</a><br clear=all>" & _ .Fields("title") & "</p>" .movenext wend .close end with set objRS = Nothing end sub
sub ShowImage (strImageName) dim strSQL, objRS strSQL = "SELECT title, description FROM PhotoAlbum " & _ "WHERE imagename = '" & strImageName & "'" set objRS = server.createobject("ADODB.Recordset") with objRS .open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText if not .EOF then response.write _ "<h1>" & .Fields("title") & "</h1>" & _ "<img src=""/image/" & strImageName & """>" & _ "<p>" & .Fields("description") & "</p>" else response.write _ "<p>No results: " & strImageName & "</p>" end if .close end with set objRS = Nothing end sub
%>
</body></html>
|