|
| |
News & Developments |

|
<%
'Create recorset object
Set rsNews = Server.CreateObject("ADODB.Recordset")
'Initalise the strSQL variable with an SQL statement to query the database by selecting all tables ordered by the decending date
strSQL = "SELECT tblNews.* FROM tblNews ORDER BY News_Date DESC;"
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsNews.CursorType = 3
'Query the database
rsNews.Open strSQL, adoCon
'Set the number of records to display on each page by the constant set in the common.asp file
rsNews.PageSize = intRecordsPerPage
'Get the record poistion to display from
If NOT rsNews.EOF Then rsNews.AbsolutePage = intRecordPositionPageNum
'If there are no rcords in the database display an error message
If rsNews.EOF Then
'Tell the user there are no records to show
Response.Write " There are no News Items to read"
Response.Write " Please check back later"
Response.End
'Display the News Items
Else
'Count the number of News Items database
intTotalNumNewsEntries = rsNews.RecordCount
'Count the number of pages of News Items there are in the database calculated by the PageSize attribute set above
intTotalNumNewsPages = rsNews.PageCount
'Display the HTML number number the total number of pages and total number of records
%>
<%
'For....Next Loop to display the News Items in the database
For intRecordLoopCounter = 1 to intRecordsPerPage
'If there are no records then exit for loop
If rsNews.EOF Then Exit For
%>
<%
'Move to the next record in the recordset
rsNews.MoveNext
Next
End If
'Display an HTML table with links to the other News Items
%>
|
<%
'If there are more pages to display then add a title to the other pages
If intRecordPositionPageNum > 1 or NOT rsNews.EOF Then
Response.Write vbCrLf & " Page: "
End If
'If the News Items page number is higher than page 1 then display a back link
If intRecordPositionPageNum > 1 Then
Response.Write vbCrLf & " << Prev "
End If
'If there are more pages to display then display links to all the pages
If intRecordPositionPageNum > 1 or NOT rsNews.EOF Then
'Display a link for each page in the News Items
For intLinkPageNum = 1 to intTotalNumNewsPages
'If the page to be linked to is the page displayed then don't make it a hyper-link
If intLinkPageNum = intRecordPositionPageNum Then
Response.Write vbCrLf & " " & intLinkPageNum
Else
Response.Write vbCrLf & " " & intLinkPageNum & " "
End If
Next
End If
'If it is Not the End of the News Items entries then display a next link for the next News Items page
If NOT rsNews.EOF then
Response.Write vbCrLf & " Next >>"
End If
'Finsh HTML the table
%>
|
<%
'Reset server objects
rsNews.Close
Set rsNews = Nothing
Set strCon = Nothing
Set adoCon = Nothing
%>
|
| |
|