Discussion Forums

<% ' Function treeMessage_Build() goes through the messages recursively, ' and shows all messages in a tree-like structure. ' This is the basis of the "threaded" discussion that is ' unique to this script. Public Sub treeMessage_Build(MessageID, Level) Dim rsMessages Set rsMessages = DB.Execute ("SELECT * FROM Messages WHERE ForumID = " & ForumID & " ORDER BY Date DESC") rsMessages.Filter = "MessageID = " & MessageID %> " HEIGHT="1">"><%= rsMessages ("Subject") %> "><%= rsMessages ("PostedBy") %> <%= ShortDate(rsMessages ("Date")) %> <% rsMessages.Filter = "InReplyTo = " & MessageID If Not (rsMessages.EOF And rsMessages.BOF) Then rsMessages.MoveFirst While Not rsMessages.EOF treeMessage_Build rsMessages("MessageID"), Level+1 rsMessages.MoveNext Wend End If End Sub %> <% If Request ("ForumID") = "" Then ' We don't have a valid ForumID, so go back to the main page. Response.Redirect "default.asp" End If Dim ForumID ForumID = Request("ForumID") Dim DB, rsForum, rsMessages, rsThreads Set DB = Connect (ForumMDB) Set rsForum = DB.Execute ("SELECT * FROM Forums WHERE ForumID = " & ForumID) Set rsMessages = DB.Execute ("SELECT * FROM Messages WHERE ForumID = " & ForumID & " ORDER BY Date DESC") Set rsThreads = DB.Execute ("SELECT * FROM Messages WHERE ForumID = " & ForumID & " AND InReplyTo = 0 ORDER BY Date DESC") If rsThreads.BOF And rsThreads.EOF Then ShowError ("

There are no messages in this forum.

") %>

Post a New Message

<% Else rsThreads.MoveFirst %>

<%= rsForum("Forum")%>

<%= rsForum("Description")%>

Post a Message

Subject Posted By Date
<% While Not rsThreads.EOF treeMessage_Build rsThreads("MessageID"), 0 rsThreads.MoveNext Wend %>

Post a Message


<% End If %>