<% Option Explicit Dim ConnectString, sql, conn, rsEntries, count, displayAmt, recordNum 'Change displayAmt to control amount of message displayed displayAmt = 15 recordNum = Request.QueryString("recordnum") ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("guestbook.mdb") Set conn = Server.CreateObject("ADODB.Connection") conn.open ConnectString sql = "SELECT * FROM guestbook ORDER BY datetime DESC" Set rsEntries = Server.CreateObject("ADODB.Recordset") rsEntries.Open sql, conn, 3, 3 %> Fran Wood

<%if rsEntries.EOF then%>

No entries in guestbook

<%else rsEntries.Movefirst 'If viewing a previous set of messages, move to the right position if recordNum <> "" and recordNum <> 0 then rsEntries.Move(recordNum) end if for count = 1 to displayAmt%>

By: <%=rsEntries("by")%>
Email: <% if rsEntries("email") <> "" then Response.Write("" & rsEntries("email") & "" else Response.Write("not given/invalid") end if %>
Date/Time: <%=rsEntries("datetime")%>

Message:
<%=rsEntries("message")%>


<%rsEntries.Movenext 'Quit loop if no more messages left if rsEntries.EOF then exit for end if next 'If there's still some more messages after displaying the first 20, display a link to the next page, using the .AbsolutePosition property as a placeholder (an ID field in the database is not reliable enough if manual DB deletions occur) 'We use .AbsolutePostion - 1 because we've already done a .Movenext onto the record we want to display first on the next page %> <%if recordNum <> "" and recordNum <> 0 then%>

« Newer Messages
<%end if%> <%if not rsEntries.EOF then%> » Older Messages
<%end if%>    

<%end if%>
<% rsEntries.close set rsEntries = nothing conn.close set conn = nothing %>