Creating a "Recent Updates" List

I have a site with a Recent Updates list on the front page. Every time I add something to the site, I add an entry to the list with the day's date and what's changed. It's actually a real bind to update because I have to download the file from the server (in case any other team members have changed it) make the changes in Dreamweaver, and then upload it again.

What would be really cool, thought I, was if I could have the text in a database, and get the page to pull say, the most recent three from the database and display them on the page. What's more, I could update this database via a web form - eliminating the need to use Dreamweaver at all - I could do it online in just a few seconds...

Come on, you want one now don't you?! Shall we build one? I think we should!

The Database

We first need to set up our database. I'm going to make mine in Access. I only need one table with three fields.

  1. newsID - this is the primary key, and the unique identifier for each record. It's set to be an AutoNumber, so that it increments itself without me having to worry.
  2. newsDate - in order to get the Date field to insert today's date automatically, I set the default value to Date().
  3. newsText - what I want to say on the page. This would be a 'memo' field so that I can have more than 255 characters.

. I'm going to call my table dwfNews.

If you've not already done so, set up a DSN and Dreamweaver connection for this database.

You may like to take the opportunity to enter 3 or 4 dummy entries into your database. This will help you test your page. You can always delete them later on.

Back in DMX, open up your site's home page (make sure you have a backup first!). You need to create some place-holders where you would like your Recent Updates list to go. I've put 'theDate' where I want the date to appear, and 'myNewsItem' as a place holder for the main text of my news item.

Next we need to set up a Recordset. A recordset is just a fancy way of saying 'a bunch of records'. Recordsets are created in the Bindings panel.

Click the big PLUS button and select Recordset (Query).

You should then get a window looking a whole lot like this... (I can tell you're finding this exciting)

I've called my Recordset "rsRecentUpdates" - note I've put the "rs" to remind me it's a recordset which is not essential but I personally find it helpful.

I then selected the connection I made earlier from the list. The Table list should then fill up, and you can select the table with your Recent Updates data in it - if you remember, mine was called dwfNews.

The last thing I've done is chosen to sort on the newsDate field. I chose Descending so that the most recent dates will be at the top of the list.

Now the really cool part - click Test.

And there's the dummy entries I put in the database! It works! Milkybars are on me! (that's an English thing).
Click OK and OK to confirm the Test and Recordset windows.

You'll see some cool looking things appear in the Bindings panel.

Next, read how to place the dynamic data onto your page »