% Option Explicit Dim ConnectString,sql,conn,rsEntries,count 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 %>
The guestbook has been closed - you can no longer add a message |
|||
|
<%if rsEntries.EOF then%> No entries in guestbook <%else rsEntries.Movefirst 'If viewing a previous set of messages, move to the right position if Request.QueryString("recordnum") <> "" then rsEntries.Move(Request.QueryString("recordnum")) end if for count = 1 to 15%> 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 not rsEntries.EOF then%> <%end if%> <%end if%> |
|||