PDA

View Full Version : photo gallery scripts


CarlosSanchez
01-02-2003, 06:04 AM
I wanted to make a website that has a photo gallery of cars. I've seen on other similar sites, they have a gallery page that shows 1 - 10 pictures, and a button that allows you to view the 11 - 20, then if you view the 11 - 20 pictures, another button allows you to view the 21 - 30 pictures.

Is there any asp free scripts out there that can do this? I'm assuming it's pulling from a directory or database? Or to do this, would I need to fully know asp and custom write a script?

Any suggestions would help. Thanks

NinjaTurtle
01-02-2003, 07:00 AM
yes there are a lot, u can try to use these sample code(but not complete):

iPageSize = 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
Set PageRS = Server.CreateObject("ADODB.Recordset")
set rsSys = server.createobject("ADODB.Recordset")
strpagesql = "Select * from table"
PageRS.PageSize = iPageSize
PageRS.CacheSize = iPageSize
PageRS.CursorLocation = 3
PageRS.Open strpagesql, objConn, adOpenKeyset, adLockPessimistic, adCmdText
iPageCount = PageRS.PageCount
TotalRecord = PageRS.RecordCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

If iPageCount = 0 Then
...


hope can giv u some hints.
any thing just post ur problem again...

Mr J
01-02-2003, 05:46 PM
If I have misunderstood your question and you specifically want to use server side, ignore the following.

Create a HTML doc that will show the first 10 images (cars1.html)


<HTML><HEAD><TITLE>cars1.html</TITLE></HEAD>
<BODY>
<h1>Car Gallery 1</h1>
<img src="car1.jpg" width="100" height="100" alt="car1">
<img src="car2.jpg" width="100" height="100" alt="car2">
<img src="car3.jpg" width="100" height="100" alt="car3">
<img src="car4.jpg" width="100" height="100" alt="car4">
<img src="car5.jpg" width="100" height="100" alt="car5"><BR>
<img src="car6.jpg" width="100" height="100" alt="car6">
<img src="car7.jpg" width="100" height="100" alt="car7">
<img src="car8.jpg" width="100" height="100" alt="car8">
<img src="car9.jpg" width="100" height="100" alt="car9">
<img src="car10.jpg" width="100" height="100" alt="car10">
<P>
<form>
<input type="button" value="View 11 - 20" onclick="location='cars2.html'">
</form>
</BODY>
</HTML>



Then create a second doc to show from 10 to 20 (cars2.html)


<HTML><HEAD><TITLE>cars2.html</TITLE></HEAD>
<BODY>
<h1>Car Gallery 2</h1>
<img src="car11.jpg" width="100" height="100" alt="car11">
<img src="car12.jpg" width="100" height="100" alt="car12">
<img src="car13.jpg" width="100" height="100" alt="car13">
<img src="car14.jpg" width="100" height="100" alt="car14">
<img src="car15.jpg" width="100" height="100" alt="car15"><BR>
<img src="car16.jpg" width="100" height="100" alt="car16">
<img src="car17.jpg" width="100" height="100" alt="car17">
<img src="car18.jpg" width="100" height="100" alt="car18">
<img src="car19.jpg" width="100" height="100" alt="car19">
<img src="car20.jpg" width="100" height="100" alt="car20">
<P>
<form>
<input type="button" value="View 1 - 10" onclick="location='cars1.html'"><input type="button" value="View 21 - 30" onclick="location='cars3.html'">
</form>
</BODY>
</HTML>


Then a third etc.

miranda
01-03-2003, 06:04 AM
here is a code that handles paging that I used for one of my clients on the search engine I wrote for them. I left the hyperlinks in there so you can see how i handled it. You can use the bulk of the code with a few minor changes.



Dim objConn, objRS, strSQL, numRecords
Dim pageTotal, recordTeller, pageNow, recordCount 'is used 2 times for a different process...
Dim recordStart, cursorPlace, pageLength, recordsPerPage
'pageLength is the length of your page, set manually according to your layout
pageLength = 5
recordsPerPage = 10

'open the database
'in order for the RecordCount to work in ADO you must use the
'following cursor adOpenStatic
numRecords = objRS.RecordCount

If Request.QueryString("page") = "" Then
pageNow = 1
Else
pageNow = CInt(Request.QueryString("page"))
End If

'count records, this is the easiest way to do it, and as long as your db doesn't
'have k's of records it's ok to use.
Do While Not objRs.EOF
recordTeller = recordTeller + 1
objRs.MoveNext
Loop
objRs.MoveFirst
pageTotal = (numRecords / (pageLength*2))
If Int(pageTotal) = 0 then pageTotal = 1
If (pageTotal / Int(pageTotal)) <> 1 Then pageTotal = Int(pageTotal) + 1

'display page x of x
If pageNow > pageTotal Then pageNow = pageTotal
If pageNow < 1 Then pageNow = 1
Response.Write "<table width=""100%""><tr><td width=""20%"" align=""left"">"
If pageNow <> 1 Then
Response.Write "<b><a href=""music-search.asp?search=" & strSrch & "&page=" & pageNow - 1 & """>previous page</a></b> "
End If
'page selection
Response.Write "</td><td width=""60%"" align=center>Page " & pageNow & " of " & pageTotal & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
'apply record paging
Dim pageArray
If pageTotal <= 10 Then
For pageArray = 1 to pageTotal
If pageArray = pageNow Then
Response.Write "[" & pageArray & "]&nbsp;&nbsp;"
Else
Response.Write "<a href=""music-search.asp?search=" & strSrch & "&page=" & pageArray & """>" & pageArray & "</a>&nbsp;&nbsp;"
End If
Next
Else
If pageNow = 1 Then
For pageArray = pageNow to pageNow + 9
If pageArray = pageNow Then
Response.Write "[" & pageArray & "]&nbsp;&nbsp;"
Else
Response.Write "<a href=""music-search.asp?search=" & strSrch & "&page=" & pageArray & """>" & pageArray & "</a>&nbsp;&nbsp;"
End If
Next
Else
Response.Write "<b>....</b> "
For pageArray = pageNow - 2 to pageNow + 9
If pageArray = pageNow Then
Response.Write "[" & pageArray & "]&nbsp;&nbsp;"
Else
Response.Write "<a href=""music-search.asp?search=" & strSrch & "&page=" & pageArray & """>" & pageArray & "</a>&nbsp;&nbsp;"
End If
Next
End If
If pageNow <> pageTotal Then Response.Write "<b>....</b>"
End If
Response.Write "</td><td width=""20%"" align=right>"
If pageNow < pageTotal Then
Response.Write "<b><a href=""music-search.asp?search=" & strSrch & "&page=" & pageNow + 1 & """>next page</a></b>"
End If
Response.Write "</td></tr></table>" & vbNewLine
Response.Write "<div align=center><font color=blue face=Arial>"
If numRecords > 1 Then
Response.Write "Your search for <i><b>&quot;" & strSrch & " &quot;</b></i> resulted in " & numRecords & " matches found.</font></div><br>"
Else
Response.Write "Your search for <i><b>&quot;" & strSrch & "&quot;</b></i> resulted in 1 match found.</font></div><br>"
End If
'record to start with
recordStart = ((pageNow -1) * recordsPerPage)
If recordStart = 0 Then recordStart =1

'get the cursor to the right place.
Do While cursorPlace < recordStart AND NOT recordStart = 1
objRs.MoveNext
cursorPlace = cursorPlace + 1
Loop
recordCount = 0
Dim i
i = 1
Do While recordCount < pageLength And Not objRs.EOF
' 300 lines of code that you don't need were in here
If Not objRs.EOF Then objRs.MoveNext
recordCount = recordCount + 1
i = i + 1
Loop