Top News   
 

Description: Show me a few of the most recent records added to the database, and individually link them to their full record! What we have this thing do, is just show the last few (newest first) records/articles added to the database along with the date that they were added. You could just as easily link this to your inventoryor any other table in your database, but we are using it for news here, so here is the code to do that..

<%
Const adUseClient = 3
Const adOpenStatic = 3
' first, make a conn to your db named cnDZ!
%>
<html><body>
<%
' then call it and use it here:
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
rs.CacheSize = 5
rs.Open "SELECT * FROM TBLNEWS ORDER BY THEDATE DESC", cnDZ, adOpenStatic
If Not rs.EOF Then
    rs.MoveFirst
    rs.PageSize = 2 'how many news items should we show?
    maxcount = cint(rs.PageCount)
    howmanyrecs = 0
While Not rs.EOF And howmanyrecs < rs.pagesize
    Response.Write"<a href=""myPage.asp?specific="&rs("NEWSID")&""" target=""_top"">"&_
          ""&Left(rs("THEDATE"),10)&"</a><br>"&Left(rs("NEWS"),99)&"...<br><br>"
    rs.MoveNext
    howmanyrecs = howmanyrecs + 1
Wend
Else
Response.Write"No News Found!"
End If
rs.Close
Set rs = Nothing
%>
</body></html>