Although this is an old topic, I thought it could still do with answering.
As long as you can write the SQL to get the appropriate content from your database, producing the menu code is easy. These steps assume your basic menu has been produced and installed. The initial menu could be nothing more than an empty toolbar to something more compex, perhaps containing fixed menu items, different styles, and so on.
1. Connect to your data source.
2. Query the database.
3. Get the record set.
4. Loop through the record set, writing JavaScript out to the HTML document.
5. Close your record set.
6. Close your data connection.
7. Destroy the record set.
8. Destroy the data connection.
This is pretty much how it works regardless of CGI language or data source.
I use this method on many sites with many menu types.
http://hyweljenkins.co.uk/ does it - the DMB DE code that I produce is at the end of the document.