<% ' Visa endast de poster som får visas.
' Sortera posterna efter inskrivning datum o tid.
' Visa = "SELECT * FROM guestbook_fun WHERE NotShow = False ORDER BY FromDateTime DESC"
' RecSet.Open Visa, Connect
' RecSet.Open Visa, Connect, adOpenStatic, adLockOptimistic
' Declare our vars
Dim iPageSize ' How big our pages are
Dim iPageCount ' The number of pages we get back
Dim iPageCurrent ' The page we want to show
Dim strOrderBy ' A fake parameter used to illustrate passing them
Dim strSQL ' SQL command to execute
' Dim objPagingConn ' The ADODB connection object
Dim RecSet ' The ADODB recordset object
Dim iRecordsShown ' Loop controller for displaying just iPageSize records
Dim I ' Standard looping var
' Get parameters
iPageSize = 25 ' You could easily allow users to change this
' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
' Build our SQL String using the parameters we just got.
' strSQL = "SELECT * FROM sample ORDER BY " & strOrderBy & ";"
' Visa endast de poster som får visas.
' Sortera posterna efter inskrivning datum o tid.
strSQL = "SELECT * FROM guestbook_fun WHERE NotShow = False ORDER BY FromDateTime DESC"
' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM sample WHERE id=1234 ORDER BY id;"
'strSQL = "SELECT * FROM sample;"
'Response.Write "SQL Query: " & strSQL & " " & vbCrLf
' Now we finally get to the DB work...
' Create and open our connection
' Set objPagingConn = Server.CreateObject("ADODB.Connection")
' objPagingConn.Open CONN_STRING, CONN_USER, CONN_PASS
' Create recordset and set the page size
' Set objPagingRS = Server.CreateObject("ADODB.Recordset")
' objPagingRS.PageSize = iPageSize
RecSet.PageSize = iPageSize
' You can change other settings as with any RS
'objPagingRS.CursorLocation = adUseClient
' objPagingRS.CacheSize = iPageSize
RecSet.CacheSize = iPageSize
' Open RS
' objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
RecSet.Open strSQL, Connect, adOpenStatic, adLockReadOnly, adCmdText
' Get the count of the pages using the given page size
' iPageCount = objPagingRS.PageCount
iPageCount = RecSet.PageCount
' If the request page falls outside the acceptable range,
' give them the closest match (1 or max)
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
' Check page count to prevent bombing when zero results are returned!
If iPageCount = 0 Then
Response.Write "No records found!"
Else
' Move to the selected page
' objPagingRS.AbsolutePage = iPageCurrent
RecSet.AbsolutePage = iPageCurrent
' Start output with a page x of n line
%>
Amount of messages: <% Response.Write(RecSet.RecordCount) %>
<%
' Spacing
Response.Write vbCrLf
' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query.
Response.Write ("")
If iPageCurrent > 1 Then %>
[<<
Prev]
<% End If
' Show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
Response.Write ("" & I & "")
Else %>
<%= I %>
<% End If
Next 'I
If iPageCurrent < iPageCount Then %>
[Next >>]
<% End If
Response.Write("
")
' Loop through our records and ouput 1 row per record
iRecordsShown = 0
' Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Do While iRecordsShown < iPageSize And Not RecSet.EOF
%>
<%
' Datum och Tid.
Response.Write(RecSet("FromDateTime") & " ")
' Man och E-post.
ShowName = RecSet("Name")
ShowEmail = RecSet("Email")
Response.Write("Name: ")
If ShowEmail <> "" Then %>
<% =ShowName %>
<% Else %>
<% =ShowName %>
<% End If %>
<%
' Hemstad.
ShowHometown = RecSet("Hometown")
If ShowHometown <> "" Then
Response.Write("Location: " & ShowHometown)
Response.Write(" ")
End If
' Hemsida.
ShowHomepage = RecSet("Homepage")
If ShowHomepage <> "http://" Then
Response.Write("Homepage: " & ShowHomepage & "")
Response.Write(" ")
End If
' Kommentar om.
ShowAbout = RecSet("About")
If ShowAbout <> "" Then
Response.Write("Comment about: " & ShowAbout)
Response.Write(" ")
End If
%>
|
<% ' Denna koden gör att radbrytningar fungerar
ShowComments = RecSet("Comments")
If ShowComments <> "" Then
ShowComments = Replace(ShowComments , Chr(34), "''")
ShowComments = Replace(ShowComments , vbCrLf, " ") %>
<% =ShowComments %>
<% Else %>
# Inlägge saknas #
<% End If %>
<% ' Denna koden gör att radbrytningar fungerar
ShowMyComments = RecSet("MyComments")
If ShowMyComments <> "" Then
ShowMyComments = Replace(ShowMyComments , Chr(34), "''")
ShowMyComments = Replace(ShowMyComments , vbCrLf, " ") %>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<% =ShowMyComments %>
<% End If %>
|
|
|
<% ' TOMRAD MELLAN POSTERNA %>
|
<%
' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
RecSet.MoveNext
Loop
' All done - close table
End If
' Close DB objects and free variables
'objPagingRS.Close
'Set objPagingRS = Nothing
'objPagingConn.Close
'Set objPagingConn = Nothing
' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query.
Response.Write ("")
If iPageCurrent > 1 Then %>
[<<
Prev]
<% End If
' Show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
Response.Write ("" & I & "")
Else %>
<%= I %>
<% End If
Next 'I
If iPageCurrent < iPageCount Then %>
[Next >>]
<% End If %>
|