Hi
I am trying to write a page which will display 10 images in rows of 4 from database records. While I have managed to write the 4 images in a row, I have not managed to make the code which will allow you to move between pages to see images beyond 10 etc.
Instead, I get "Displaying 1 - 10 of -1 Pictures. Pages: [ 1 ]" when it should be Displaying 1 - 10 of 34 Pictures. Pages: [ 1 2 3 ] with 2 and 3 linking to the pages.
----- BEGIN CODE -----
i = 1
if isnumeric(request("i")) and request("i") <> "" then i = request("i")
Sql = "SELECT * FROM images WHERE album = " & i & " ORDER BY name"
set sl = db.Execute(Sql)
DIM intPageRecords, intRecords, intRecordCount, intCurrentPage
DIM intNumberOfPages, intDisplayPage
intPageRecords = Request.Querystring("page")
IF intPageRecords = "" THEN intPageRecords = 1 : intRecords = 1
intRecords = intPageRecords
intPageRecords = ((intPageRecords - 1) * 10) +1
intRecordCount = 0
if not sl.EOF or not sl.BOF then
sl.move (intPageRecords - 1)
%><TABLEBORDER=0CELLPADDING=4CELLSPACING=0WIDTH="100%"><%
Sql = "SELECT * FROM albums WHERE id = " & i
set sl2 = db.Execute(Sql)
if not sl2.EOF or not sl2.BOF then
name = sl2("name")
desc = sl2("description")
end if
set sl2 = NOTHING
%><tr><TDNOWRAPVALIGN=TOPcolspan=4><ahref="<%=Request.ServerVariables("url") %>"><u>Pictures</u></a><strong><font color="#084A8D"><u> » <%=name %></u></strong></font><P></td></tr><%
cnt = 0
DO WHILE intRecordCount < 10 and NOT sl.EOF
id = sl("id")
filename = "SJa/" & sl("filename")
name = sl("name")
cnt = cnt + 1
if cnt = 5 then cnt = 1
if cnt = 1 then Response.write "<tr>"
%><TDVALIGN=TOPwidth="25%"><center><ahref="javascript:Start('SJa_Show_Pic.asp?a=image&i=<%=i d %>')"><imgsrc="<%=filename %>"height=80border=0><br><%=name %></a></center><p></td><%
if cnt = 4 then Response.Write "</tr>"
sl.movenext
intRecordCount = intRecordCount +1
loop
if cnt = 1 then Response.Write "<TD NOWRAP VALIGN=TOP width=""25%""> </td>"
if cnt <= 2 then Response.Write "<TD NOWRAP VALIGN=TOP width=""25%""> </td>"
if cnt <= 3 then Response.Write "<TD NOWRAP VALIGN=TOP width=""25%""> </td></tr>"
%></table>
<%
else
%><TABLEBORDER=0CELLPADDING=4CELLSPACING=0WIDTH="100%"><tr><TDNOWRAPVALIGN=TOP><!--<pre>--><ahref="<%=Request.ServerVariables("url") %>"><u>Pictures</u></a><!--</pre>--><p>Coming Soon...</td></tr></table><p><%
end if
%>
Displaying <%=intPageRecords%> - <%=intPageRecords+(intRecordCount-1)%> of <%=(sl.RecordCount)%> Pictures.
<%
intCurrentPage = Request.Querystring("page")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(sl.RecordCount \ 10)
IF sl.RecordCount MOD 10<> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("Pages: [")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write " <b>" & intDisplayPage & "</b> "
ELSE
Response.Write " <a href=""sja_pictures.asp?a=path&i=" & i & "&page=" & intDisplayPage & """>" & intDisplayPage &_
"</a> "
END IF
NEXT
Response.Write ("]")
set sl = NOTHING
----- END CODE -----
I have managed to get the number of records per page code to work on a quotes section of my site ( http://www.waynieoaks.co.uk/sja_quotes.asp)
So I know the problem is the two sets of code on one page - but can not work it out. The non-live example of this problem can be seen at http://waynieoaks.boldlygoingnowhere...sp?a=path&i=23
Thank you for any help anyone can provide - I am by far not an expert at ASP code.
|