<% ' Just get some quick stats sql = "Select max(gbDate) as LastPost, min(gbDate) as FirstPost from tblGuestbook" set rsContent = Server.CreateObject("ADODB.Recordset") rsContent.ActiveConnection = conString rsContent.Source = sql rsContent.CursorType = 3 rsContent.CursorLocation = 2 rsContent.LockType = 1 rsContent.Open() FirstPost = (rsContent.Fields.Item("FirstPost").Value) LastPost = (rsContent.Fields.Item("LastPost").Value) rsContent.Close() Set rsContent = Nothing ' get all the guestbook entries sql = "Select * from tblGuestbook order by gbDate DESC" set rsContent = Server.CreateObject("ADODB.Recordset") rsContent.ActiveConnection = conString rsContent.Source = sql rsContent.CursorType = 3 rsContent.CursorLocation = 2 rsContent.LockType = 1 rsContent.Open() total = rsContent.RecordCount ' set a value of how many entries to show per page showPages = 10 %> Peter Ellegard - International Freelance Travel Writer and Photographer

Peter's Guestbook

Thank you for your comments.

[ Post Message ]

There <% if total > 1 then response.write("are") else response.write("is") end if %> a total of <%=total%> comment<% if total > 1 then response.write("s") end if %> in the guestbook entered between <%=FirstPost%> and <%=LastPost%>.

<% ' show this many count = showPages ' currently on this many starthere = request.querystring("r") if starthere = "" then starthere=0 end if if total > 0 then %> <% ' if total > 0 then we have some entries ' Move to the the correct record rsContent.move(starthere) ' loop while we have records to show and we're below the number of ' entries to show per page While (NOT rsContent.EOF and count >0) if (rsContent.Fields.Item("gbEmail").Value) <> "" then thename = "" & (rsContent.Fields.Item("gbName").Value) & "" else thename = (rsContent.Fields.Item("gbName").Value) end if %> <% ' here would be a good place to add a "Delete" link for peter to delete spam ' first check the session variable to see if he's logged in.... if session("lev") = "" then session("lev") = 0 end if if session("lev") >= 99 then ' then a level 99 user is logged so display the links to delete a post %> <% end if %> <% RecordTo = starthere+showPages if RecordTo > total then RecordTo = total end if count = count-1 rsContent.movenext() Wend %>
Name: <%=thename%>
Subject: <%=(rsContent.Fields.Item("gbHeading").Value)%>
Comments: <%=replace((rsContent.Fields.Item("gbComments").Value), vbcrlf, "
")%>
Posted: <%=(rsContent.Fields.Item("gbDate").Value)%>
Delete? ">Delete this post

<% end if rsContent.Close() Set rsContent = Nothing %>
<% if (starthere-showPages) >= 0 then%> Previous  <% end if %>
Showing <%=starthere+1%> to <%=RecordTo%> of <%=total%>
<% ' if adding showPages is < the total records its safe to have a "Next" link if (starthere+showPages) < total then %> Next <%end if%>