The first thing you need to do is create a database called MyDatabase. Then create a table called tblScripts with these fields:
ID - autonumber
Script - text field
DateEntered - date/time field *** Also add "=Date()" as the default value for the field. This will add the date automatically, everytime a new record is entered. ***
Then, start adding some data to your database. If you leave the database empty, the script will simply display a blank page.
Next, you create a page called displaytop10.asp and copy the below code into your page:
<% DIM mySQL, objRS mySQL = "SELECT TOP 10 * FROM tblScripts ORDER BY DateEntered DESC" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open mySQL, objConn %>
Our Latest Scripts |
<%=objRS("Script")%> |
<% iRecordCount = iRecordCount + 1 objRS.MoveNext Loop objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %> |
This will display the top 10 most recent records that were entered into your database
http://www.aspwebpro.com/aspscripts/database/top10.asp
No comments:
Post a Comment