<html>
<head>
<title>My Guestbook</title>
</head>
<body bgcolor="black" text="#C5BE60" topmargin=0 leftmargin=0>
<center>
<font face="times new roman">
<i><h1>My Guestbook</h1></i><p>
</font>
<%
If request.form("PageNo")="" then
PageNo=1
Else
PageNo=request.form("PageNo")
End If
If PageNo=1 then
%>
<font face="arial" size=3>
<a href="sign.asp">Sign the Guestbook</a>
<p>
<font face='arial' size=2>Would you like to use this guestbook on your ASP-enabled site?
<br><a href="guestbook.zip">Download the guestbook files</a><p>
<%
Else
%>
<font face="arial" size=3>
<a href="sign.asp">Sign the Guestbook</a>
<p>
<%
End If
set conn = server.createobject("adodb.connection")
conn.open "guestbook"
sqlstmt = "SELECT * from Guestbook ORDER BY Date DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlstmt, conn, 3, 3
' TotalRecs is the total number of records in the recordset
TotalRecs = rs.recordcount
' pagesize refers to the number of records displayed on each page
rs.Pagesize=10
' the following line automatically figures out how many pages
' are needed for the recordset
TotalPages = cInt(rs.pagecount)
' the next line tells the recordset which page you'd like to work with
rs.absolutepage=PageNo
If PageNo = 1 then
response.write "<br><Font face='arial' size=2>There are "
response.write TotalRecs & " entries in "
response.write TotalPages & " pages</font>"
End If
If rs.eof then
response.write "<p><br><center><font face='arial'>"
response.write "<b>There are no entries in the guestbook.</b>"
response.write "<br><a href='sign.asp'>Sign the Guestbook</a>"
response.write "</font></center>"
response.end
End If
x = 0
' let's display the 10 records on the page
For x = 1 to 10
If rs.eof then
Exit For
Else
When = rs("Date")
Name = rs("Name")
Name = Replace(Name,"''","'")
City = rs("City")
State = rs("State")
Country = rs("Country")
Email = rs("Email")
URL = rs("URL")
If IsEmpty(URL) or URL = "" then
Link = "no URL given"
Else
Link = "<a href=""" & URL & """>" & URL & "</a>"
End If
Comments = rs("Comments")
Comments = replace(Comments, "''", "'")
Start = rs("PostDate")
%>
<table width=600 border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=3><font face="arial" size=2><%= When %></td></tr>
<tr>
<td colspan=3 bgcolor="#C5BE60"><font face="arial" size=2 color="#000000">
<b><%= Comments %></b></font>
</td>
</tr>
<tr>
<td width=125 valign="top">
<font face="arial" size=1>
<%
If IsEmpty(Email) or Email="" then
response.write Name
Else
response.write "<a href='mailto:" & Email & "'>" & Name & "</a>"
End If
%>
</font>
</td>
<td width=200 valign="top"><font face="arial" size=1><i><%= City %>
<%= State %> <%= Country %></i>
</td>
<td width=275 align="right" valign="top">
<font face="arial" size=1><%= Link %>
</font>
</td>
</tr>
</table>
<br>
<%
rs.MoveNext
End If
Next
' now let's set up the navigation...
response.write "<table width=300 border=0><tr>"
response.write "<td align='center'>"
' we don't want "Previous" on the first page so we'll do this
If PageNo > 1 then
response.write "<form method='post' action='default.asp'>"
response.write "<input type='hidden' name='Page' value='" & PageNo-1 & "'>"
response.write "<font face='arial' size=2>"
response.write "<input type='submit' value='<< Prev'></form>"
Else
response.write " "
End If
response.write "</td><td align='center'>"
' we don't want "Next" on the last page so we'll do this
If NOT rs.eof then
response.write "<form method='post' action='default.asp'>"
response.write "<input type='hidden' name='Page' value='" & PageNo+1 & "'>"
response.write "<font face='arial' size=2>"
response.write "<input type='submit' value='Next >>'></form>"
Else
response.write " "
End If
response.write "</td></tr></table>"
rs.close
set rs=nothing
conn.close
set conn = nothing
%>
</center>
</body>
</html>
Fax this page
|