% Dim rsJournal 'Database recordset holding the Journal items Dim rsCommentsCount 'Database recordset holding the count of comments for each Journal item Dim intRecordPositionPageNum 'Holds the number of the page the user is on Dim intRecordLoopCounter 'Loop counter to loop through each record in the recordset Dim intTotalNumJournalEntries 'Holds the number of Journal Items there are in the database Dim intTotalNumJournalPages 'Holds the number of pages the Journal Items cover Dim intLinkPageNum 'Holds the number of the other pages of Journal itmes to link to 'If this is the first time the page is displayed then set the record position is set to page 1 If Request.QueryString("PagePosition") = "" Then intRecordPositionPageNum = 1 'Else the page has been displayed before so the Journal item record postion is set to the Record Position number Else intRecordPositionPageNum = CInt(Request.QueryString("PagePosition")) End If %>
<% DisplayContent 2,1392,1,12,0,1,0,0,0,0,1,0,"Links","140","topic.asp" %> | <%
'Create recorset object
Set rsJournal = Server.CreateObject("ADODB.Recordset")
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblJournal.* FROM tblJournal ORDER BY Date_stamp DESC;"
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsJournal.CursorType = 3
'Query the database
rsJournal.Open strSQL, adoCon
'Set the number of records to display on each page by the constant set in the common.asp file
rsJournal.PageSize = intRecordsPerPage
'Get the record poistion to display from
If NOT rsJournal.EOF Then rsJournal.AbsolutePage = intRecordPositionPageNum
'Create recorset object
Set rsCommentsCount = Server.CreateObject("ADODB.Recordset")
'If there are no rcords in the database display an error message
If rsJournal.EOF Then
'Tell the user there are no records to show
Response.Write " There are no Journal Items to read" Response.Write " Please check back later" Response.Write " " Response.Write "Photo Album Administrator Options " Response.End 'Display the Journal Items Else 'Count the number of Journal Items database intTotalNumJournalEntries = rsJournal.RecordCount 'Count the number of pages of Journal Items there are in the database calculated by the PageSize attribute set above intTotalNumJournalPages = rsJournal.PageCount 'Display the HTML number number the total number of pages and total number of records %>
<% 'For....Next Loop to display the Journal Items in the database For intRecordLoopCounter = 1 to intRecordsPerPage 'If there are no records then exit for loop If rsJournal.EOF Then Exit For 'Get the count of comments from the db strSQL = "SELECT Count(tblComments.Journal_ID) AS CountOfJournalItems " strSQL = strSQL & "FROM tblComments " strSQL = strSQL & "WHERE tblComments.Journal_ID = " & CLng(rsJournal("Journal_ID")) & ";" 'Query the database rsCommentsCount.Open strSQL, adoCon %>
<% 'Close the count recordset rsCommentsCount.Close 'Move to the next record in the recordset rsJournal.MoveNext Next End If 'Display an HTML table with links to the other Journal Items %>
<% 'Reset server objects rsJournal.Close Set rsJournal = Nothing Set rsCommentsCount = Nothing Set strCon = Nothing Set adoCon = Nothing %> |