<%
MYSQL = "SELECT ID, USER_DATE, USER_NAME, USER_CITY, USER_MAIL, USER_URL, USER_MESSAGE FROM GBOOK ORDER by ID DESC"
rs.Open MySQL, dc, 3, 1
%>
<%
'this is the records counter and navigation stuff
currentPage = request.queryString ("id") 'check what page to dysplay (this is used for nav)
If currentPage = "" then
currentPage = "1"
End If
pageSize = 50 'pageSize is the ammout of records per page to be dysplayed
Records = rs.RecordCount 'this is the total ammount of records in the DB
if NOT (Records = 0) then 'if there are no records in the DB, server may report an error. I used the IF structure to prevent this error.
rs.pageSize = pageSize
rs.AbsolutePage = currentPage 'absolutePage is the page to be dysplayed - don't change it: it depeds on the user's choice
End If
pageNext = currentPage + 1
pagePrev = currentPage - 1
Pages = Records \ pageSize
if Records mod pageSize then
Pages = Pages + 1
End If
%>
| Pages: <% if NOT pagePrev < 1 then %>>Prev <% else %> Prev <% End If %> | <% While NOT pageNumber = Pages pageNumber = pageNumber + 1 %> <% if CInt (pageNumber) = CInt (currentPage) then %> <% = pageNumber %> | <% else %> > <% = pageNumber %> | <% End If %> <% Wend %> <% if NOT pages < pageNext then %> >Next <% else %> Next <% End If %> |
Total entries: <% = Records %> |
<%
if NOT (CInt(Records) = 0) then 'if there are no records in the database it doesn't go on dysplaying then and only sais that there are no records
Do While (Not rs.EOF) and (currentRecords < pageSize) 'runs through the records and dysplays them
currentRecords = currentRecords + 1 'counts currently dysplayed records
%>
Mitteilung: <%= rs("USER_MESSAGE") %> |
<%
rs.MoveNext
Loop
else
response.write ("No records found, be the first to post a comment! ") & VBCRLF
End If
%>
<% 'closing connections and resetting all database variables
rs.Close
Set rs = Nothing
dc.Close
Set dc = Nothing
%>
|