For some time now I've wanted a better way to share the questions that I get emailed each day. My answer was to create a "diary", stored in the database, that allows me to post any amount of chit-chat, bug fix notifications and tips. It was extremely easy to implement. First I created a new Diary table, which I add/edit/delete using my database admin pages. I couldn't just display the list on the front page though, because some days may have very long entries in them, so I decided to use an <IFRAME;> tag instead. This gives a scrolling frame that you can effectively display a large amount of text in a small space. <iframe src="/ShowDiary.html" width="100%" height="150" marginheight=0 marginwidth=0>
<a href="/ShowDiary.html">Visit the Diary</a>
</iframe>
|
Anyone who uses a browser that doesn't support <IFRAME>'s will see a link instead, and they can always turn the diary off in the membership personalization page. To put content into the <IFRAME> you need a new page. I created ShowDiary.asp, which just gets the data from the database, sorted by date, and displays them all. Note that this doesn't use the normal Header () and Footer () functions since this won't normally be used as a standalone page. The code basically does what is shown below. For the full source code click the "Get the Source" icon below. DBInitConnection ( );
DBGetRecords ( 'SELECT DiaryDate,Entry FROM Diary ORDER BY DiaryDate DESC' );
while ( !oRecordSet.EOF )
{
var sDate = '' + oRecordSet ( 0 );
var sEntry = '' + oRecordSet ( 1 );
// display data
oRecordSet.MoveNext();
}
DBReleaseConnection ( );
|
Note that the DB.. functions are utility functions included in utils/database.asp - a file available in the download. |