I've used flamewaves example and adjusted the code...it seems I'm still missing something here..
The page works without errors and does display rows and colums. The colums seem to work fine, but the rows show the existing items returned from the database over and over again without going to the next files (so it displays the first 4 items from the database, but doesn't show the next two remaining items in the next row)..
I've named the files: test 1, test 2 etc till test 6
See here:http://129.125.101.174/dark%20project/fldisplay.asp?page=1&id=4 (again refresh the page if you first receive an error).
What has to be added or changed in order to get the correct rows and colums returned?
Here is the adjusted code:
<%
'Make sure this page is not cached
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "No-Store"
'new code gallery
'set to true if you are using a database and need a recordset
Const blnNeedRecordset = True
'Column and Row constants, the number of columns and rows you want displayed on each page
Const NUM_COLUMNS = 4
Const NUM_ROWS = 10
'old code
SET Conn = Server.CreateObject("ADODB.Connection")
SET rsDispItems = Server.CreateObject("ADODB.RecordSet")
SUB OpenDB(sConn)
Conn.Open sConn
SET rsDispItems.ActiveConnection = Conn
rsDispItems.CursorType = AdOpenStatic
END SUB
SUB CloseDB(sConn)
rsDispItems.Close
Conn.Close
END SUB
OpenDB strCon
'new code gallery
'declare variables
Dim intOuterTableLoopCounter
Dim intInnerTableLoopCounter
Dim intTotalNumRecords
Dim rsDispItems
Dim intPageNum
Dim intNumFilePages
Dim intPageLoopCounter
Dim intItemCount
'get the current page number
intPageNum = Clng(Request.QueryString("Page"))
If intPageNum < 1 Then intPageNum = 1
'initilize the total number of records to 0
intTotalNumRecords = 0
%>
<%
SQL = "SELECT * FROM LibrariesCategories WHERE ID = " & Request("ID")
SET rsDispItems = Conn.Execute(SQL)
ID = rsDispItems("ID") %>
<% Response.Write (rsDispItems("CategoryName") & " " & "<A HREF='fladd.asp?CatID=" & Request("ID") & "'>Upload a File</A>")%>
<html>
<head>
<title>Page Title</title>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td align="center"><h1><font size="2">download gallery</font></h1></td>
</tr>
<tr>
<td>
<%
If blnNeedRecordset Then
'create a recordset and open it
Set rsDispItems = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM LibrariesFiles WHERE CatID = " & Request("ID") & " AND Approved=true ORDER BY FileName"
'set the cursor type so we can move back and forth between records
rsDispItems.CursorType = 1
rsDispItems.Open strSQL, adoCon
'if records were returned then get the page information
If NOT rsDispItems.EOF Then
'dynamicaly determine how many records will be displayed on the page
rsDispItems.Pagesize = NUM_ROWS * NUM_COLUMNS
'set the current page number
rsDispItems.AbsolutePage = intPageNum
If rsDispItems.EOF AND intPageNum > 1 Then rsDispItems.AbsolutePage = 1
'get the number of pages
intNumFilePages = rsDispItems.PageCount
'get the number of records returned
intTotalNumRecords = rsDispItems.RecordCount
End If
Else
intTotalNumRecords = NUM_ITEMS
intNumFilePages = Clng(FormatNumber((((intTotalNumRecords - 1) / (NUM_ROWS * NUM_COLUMNS)) + 0.5), 0))
'Response.Write intNumFilePages
'Response.End
End If
intItemCount = (intPageNum * (NUM_ROWS * NUM_COLUMNS)) - ((NUM_ROWS * NUM_COLUMNS) - 1)
'If there is more than 1 page of images then dispaly links to the other pages
If intNumFilePages > 1 Then
'Display an image link to the last topic
Response.Write vbCrLf & "<div class=""text"" align=""center"">Display Page: "
'If we are not on the first page then display a previous link
If intPageNum <> 1 Then Response.Write "<a href=""fldisplay.asp?Page=" & intPageNum - 1 & """><< Prev</a> "
'Loop round to display links to all the other pages
For intPageLoopCounter = 1 to intNumFilePages
'Display the numerical links to each page
If intPageLoopCounter = intPageNum Then
Response.Write vbCrLf & " " & intPageLoopCounter & " "
Else
Response.Write vbCrLf & " <a href=""fldispay.asp?Page=" & intPageLoopCounter & """>" & intPageLoopCounter & "</a> "
End If
Next
'If we are not on the last page then display a next link
If intPageNum <> intNumFilePages Then Response.Write " <a href=""fldisplay.asp?Page=" & intPageNum + 1 & """>Next >></a>"
Response.Write "<br><br>" & vbCrLf
End If
If intTotalNumRecords = 1 Then
Response.Write "<p align=""center"">There is " & intTotalNumRecords & " item in this category.</p>" & vbCrLf
Else
Response.Write "<p align=""center"">There are " & intTotalNumRecords & " items in this category.<br>" & vbCrLf
If intTotalNumRecords <> 0 Then
If intPageNum = intNumFilePages Then
Response.Write "Showing items " & intItemCount & " through " & intTotalNumRecords & " of " & intTotalNumRecords & ".</p>" & vbCrLf
Else
Response.Write "Showing items " & intItemCount & " through " & (intPageNum * (NUM_ROWS * NUM_COLUMNS)) & " of " & intTotalNumRecords & ".</p>" & vbCrLf
End If
End If
End If
%>
<%
SQL = "SELECT * FROM LibrariesCategories WHERE ID = " & Request("ID")
SET rsDispItems = Conn.Execute(SQL)
ID = rsDispItems("ID") %>
<table border="0" width="95%" align="center" cellspacing="10">
<%
'row loop
For intOuterTableLoopCoun