001  <HTML>
002  <HEAD>
003  <TITLE>Einträge im Gästebuch</TITLE>
004  </HEAD>
005  <BODY BGCOLOR="#ffffff">
006  
007  <H1>Einträge im Gästebuch</H1>
008  <%
009  strConnection = "Driver={Microsoft Access Driver (*.mdb)};DBQ="
010  strConnection = strConnection & Server.MapPath("guestbook2000.mdb")
011  strConnection = strConnection & ";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5;"
012  
013  ' korrekt nach Datum absteigend sortiert; first ten records
014  Const cstrFirstTenRecords = "SELECT TOP 10 IdField,Name,EmailAddress,Homepage,Browser,OperatingSystem,EntryDate,Comment from Guestbook ORDER BY IdField DESC"
015  ' next ten records
016  Const cstrNextTenRecP1 = "SELECT TOP 10 IdField,Name,EmailAddress,Homepage,Browser,OperatingSystem,EntryDate,Comment from Guestbook WHERE IdField < "
017  Const cstrNextRecP2 = " ORDER BY IdField DESC"
018  ' previous ten records; WRONG SORT ORDER INITIALLY!
019  Const cstrPrevTenRecP1 = "SELECT TOP 10 IdField,Name,EmailAddress,Homepage,Browser,OperatingSystem,EntryDate,Comment from Guestbook WHERE IdField > "
020  Const cstrPrevRecP2 = " ORDER BY IdField ASC"
021  
022  strPageDirection = Trim(Request.QueryString("Page"))
023  If "" = strPageDirection Then strPageDirection = "Start"
024  nLastIndex = Trim(Request.QueryString("Index"))
025  If ("" = nLastIndex Or Not IsNumeric(nLastIndex)) Then strPageDirection = "Start"
026  
027  Select Case strPageDirection
028   Case "Next"
029   strSQL = cstrNextTenRecP1 & nLastIndex & cstrNextRecP2
030   Case "Prev"
031   strSQL = cstrPrevTenRecP1 & nLastIndex & cstrPrevRecP2
032   bTopDown = True
033   Case Else
034   strSQL = cstrFirstTenRecords
035  End Select
036  
037  Set conn = CreateObject("ADODB.Connection")
038  conn.Open strConnection
039  Set rs = CreateObject ("ADODB.Recordset")
040  rs.Open strSQL, conn
041  
042  If Not rs.EOF and Not rs.BOF Then
043   avarRecords = rs.GetRows()
044  Else
045   bNoRecords = True
046  End If
047  
048  rs.Close
049  
050  ' get summary information
051  rs.Open "SELECT * FROM qSummaries", conn
052  nTotalRecords = rs(0)
053  If nTotalRecords <> 0 Then
054   rs.MoveNext
055   nTotalMax = rs(0)
056   rs.MoveNext
057   nTotalMin = rs(0)
058  End If
059  rs.Close
060  
061  conn.Close
062  Set rs = Nothing
063  Set conn = Nothing
064  
065  strScriptName = Request.ServerVariables("SCRIPT_NAME")
066  If Not bNoRecords Then
067   nRecords = UBound(avarRecords,2)
068   If Not bTopDown Then
069   nPrevPaging = avarRecords(0,0)
070   nLastPaging = avarRecords(0,nRecords)
071   Else
072   nPrevPaging = avarRecords(0,nRecords)
073   nLastPaging = avarRecords(0,0)
074   End If
075  
076   Response.Write "<TABLE WIDTH=""500"">"
077   Response.Write "<TR><TD COLSPAN=""2"" bgcolor=""#003399""><font color=""white""><b>Anzahl Einträge: " & nTotalRecords
078   Response.Write "</b></font></td></tr>" & vbCrLf
079   WritePagingHeaders
080  
081   If Not bTopDown Then
082   For intRecord = 0 To nRecords
083   WriteRecord avarRecords, intRecord
084   Next
085   Else
086   For intRecord = nRecords To 0 Step -1
087   WriteRecord avarRecords, intRecord
088   Next
089   End If
090   WritePagingHeaders
091   Response.Write "</TABLE>"
092  Else
093   Response.Write "<p>Keine Eintragungen gefunden!</p>"
094  End If ' bNoRecords
095  
096  Sub WriteRecord(avarRecords, intRecord)
097   Response.Write "<TR><TD valign=""top"">"
098   Response.Write "<b>Name:</b> " & avarRecords(1,intRecord) & "<br>"
099   Response.Write "<b>eMail:</b> "
100   If "" <> avarRecords(2,intRecord) Then
101   Response.Write "<a href=""mailto:" & avarRecords(2,intRecord) & """>"
102   Response.Write avarRecords(2,intRecord) & "</a>"
103   Else
104   Response.Write "keine"
105   End If
106   Response.Write "<br>"
107   Response.Write "<b>Homepage:</b> "
108   If "" <> avarRecords(3,intRecord) Then
109   Response.Write "<a href=""http://" & avarRecords(3,intRecord) & """ target=#quoted2#_new#quoted2#>"
110   Response.Write "http://" & avarRecords(3,intRecord) & "</a>"
111   Else
112   Response.Write "keine"
113   End If
114   Response.Write "<br>"
115   Response.Write "<b>Kommentar:</b> " & Replace(avarRecords(7,intRecord),vbCrlf,"<br>") & "<br>"
116   Response.Write "</TD><TD valign=""top"" align=""right"">"
117   Response.Write avarRecords(5,intRecord) & " / " & avarRecords(4,intRecord)
118   Response.Write "<br><b>" & avarRecords(6,intRecord) & "</b>"
119   Response.Write "</td></tr>" & vbCrLf
120   Response.Write "<tr><td colspan=2><hr></td></tr>" & vbCrlf
121  End Sub
122  
123  Sub WritePagingHeaders()
124  %>

125   <TR><TD colspan="2" bgcolor="#FFFFCC">
126   <table border="0" cellspacing="1">
127   <tr>
128   <td>
129   <%
130   If nTotalMax > nPrevPaging Then
131   Response.Write "<a href=""" & strScriptName & "?Page=Prev&Index=" & nPrevPaging
132   Response.Write """>10 zurück</a>"
133   Else
134   Response.Write "10 zurück"
135   End If
136   %>

137   </td>
138   <td><b>|</b></td>
139   <td><a href="<%=strScriptName & "?Page=Start"%>">anfang</a></td>
140   <td><b>|</b></td>
141   <td>
142   <%
143   If nTotalMin < nLastPaging Then
144   Response.Write "<a href=""" & strScriptName & "?Page=Next&Index=" & nLastPaging
145   Response.Write """>nächsten 10</a>"
146   Else
147   Response.Write "nächsten 10"
148   End If
149   %>

150   </td>
151   </tr>
152   </table>
153   </td></tr>
154  <%
155  End Sub
156  %>

157  
158  </BODY>
159  </HTML>