% Option Explicit %>
<%
Response.Buffer = True
Dim rsGuestbook 'Database Recordset Variable
Dim strName 'Holds the Users name
Dim strEmailAddress 'Holds the Users e-mail address
Dim strCountry 'Holds the users country
Dim strHomepage 'Holds the Users homepage
Dim strComments 'Holds the Users comments
Dim dtmEntryDate 'Holds the date the commnets where made
Dim intRecordPositionPageNum 'Holds the record position
Dim intRecordLoopCounter 'Loop counter for displaying the guestbook records
Dim intTotalNumGuestbookEntries 'Holds the total number of records in the database
Dim intTotalNumGuestbookPages 'Holds the total number of pages in the database
Dim intLinkPageNum 'Holds the page number to be linked to
If Request.QueryString("PagePosition") = "" Then
intRecordPositionPageNum = 1
Else
intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblComments.* FROM tblComments ORDER BY Date_stamp DESC;"
rsGuestbook.CursorType = 3
rsGuestbook.Open strSQL, adoCon
rsGuestbook.PageSize = intRecordsPerPage
If NOT rsGuestbook.EOF Then rsGuestbook.AbsolutePage = intRecordPositionPageNum
%>
GuestBook
GuestBook
Welcome to
Dwyer's Irish Pub GuestBook.
If you would like to sign
the guest book then click
on the link below.
<%
If rsGuestbook.EOF Then
'Tell the user there are no records to show
Response.Write " There are no records in the guestbook database"
Response.Write " Please check back later"
Response.End
Else
intTotalNumGuestbookEntries = rsGuestbook.RecordCount
intTotalNumGuestbookPages = rsGuestbook.PageCount
%>
There are <% = intTotalNumGuestbookEntries %> guestbook entries in <% = intTotalNumGuestbookPages %> pages and you are on page number <% = intRecordPositionPageNum %>
<%
For intRecordLoopCounter = 1 to intRecordsPerPage
If rsGuestbook.EOF Then Exit For
strName = rsGuestbook("Name")
strCountry = rsGuestbook("Country")
strEmailAddress = rsGuestbook("EMail")
dtmEntryDate = CDate(rsGuestbook("Date_stamp"))
strHomepage = rsGuestbook("Homepage")
strComments = rsGuestbook("Comments")
If strHomepage = "http://" then
strHomepage = "no URL given"
Else
strHomepage = "" & strHomepage & ""
End If
%>
Comments by
<%
If strEmailAddress <> "" Then Response.Write("" & strName & "") Else Response.Write(strName)
%> on <% = FormatDateTime(dtmEntryDate, VbLongDate) %> at <% = FormatDateTime(dtmEntryDate, VbShortTime) %>
IP Logged
<% = strComments %>
<% = strCountry %>
<% = strHomepage %>
<%
rsGuestbook.MoveNext
Next
End If
%>
<%
If intRecordPositionPageNum > 1 or NOT rsGuestbook.EOF Then
Response.Write vbCrLf & " Page: "
End If
If intRecordPositionPageNum > 1 Then
Response.Write vbCrLf & ("<< Prev")
End If
If intRecordPositionPageNum > 1 or NOT rsGuestbook.EOF Then
For intLinkPageNum = 1 to intTotalNumGuestbookPages
If intLinkPageNum > 15 Then
If intTotalNumGuestbookPages = intRecordPositionPageNum Then Response.Write(" ..." & intTotalNumGuestbookPages) Else Response.Write(" ..." & intTotalNumGuestbookPages & "")
Exit For
Else
If intLinkPageNum = intRecordPositionPageNum Then Response.Write(" " & intLinkPageNum) Else Response.Write(" " & intLinkPageNum & "")
End If
Next
End If
If NOT rsGuestbook.EOF then
Response.Write (" Next >>")
End If
%>
<%
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
Set strCon = Nothing
%>