<% Option Explicit %> Welcome to ThaiChain.com Home Page

Thai Chain Discussion Forum

<% 'If the user has logged in then the Logged In User ID number will be more than 0 If NOT lngLoggedInUserID = 0 Then 'Dispaly a welcome message to the user in the top bar Response.Write vbCrLf & "" 'Else the user is not logged Else 'Display a welcome guset message with the option to login or register Response.Write vbCrLf & "" End If %>
Welcome " & strLoggedInUsername & "     Welcome Guest      

<% 'Dimension variables Dim rsForum 'Holds the Recordset for the forum details Dim rsTopicCount 'Holds the Recordset for the count of Topics Dim rsThread 'Holds the recordset for the thread details Dim intForumID 'Holds the forum ID number Dim lngTopicID 'Holds the topic id number Dim strForumName 'Holds the forum name Dim strForumDiscription 'Holds the forum description Dim dtmForumStartDate 'Holds the forum start date Dim lngNumberOfTopics 'Holds the number of topics in a forum Dim lngNumberOfPosts 'Holds the number of Posts in the forum Dim dtmLastEntryDate 'Holds the date of the last entry to the forum Dim strLastEntryUser 'Holds the the username of the user who made the last entry Dim lngLastEntryUserID 'Holds the ID number of the last user to make and entry 'Craete a recordset to get the forum details Set rsForum = Server.CreateObject("ADODB.Recordset") 'Read the various forums from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblForum.* FROM tblForum;" 'Query the database rsForum.Open strSQL, strCon 'Check there are forum's to display If rsForum.EOF Then 'If there are no forum's to display then display the appropriate error message Response.Write vbCrLf & "" 'Else there the are forum's to write the HTML to display it the forum names and a discription Else 'Create a record set object to the Topics held in the database Set rsTopicCount = Server.CreateObject("ADODB.Recordset") 'Get the number of Topics 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT Count(tblTopic.Forum_ID) AS Topic_Count, tblTopic.Forum_ID " strSQL = strSQL & "From tblTopic " strSQL = strSQL & "GROUP BY tblTopic.Forum_ID " 'Query the database rsTopicCount.Open strSQL, strCon 'Create a record set object to the Threads held in the database Set rsThread = Server.CreateObject("ADODB.Recordset") 'Initalise the strSQL variable with an SQL statement to query the database for the date of the last entry and the author for the thread strSQL = "SELECT tblThread.Message_date, tblAuthor.Username, tblAuthor.Author_ID, tblTopic.Forum_ID " strSQL = strSQL & "FROM (tblForum INNER JOIN tblTopic ON tblForum.Forum_ID = tblTopic.Forum_ID) INNER JOIN (tblAuthor INNER JOIN tblThread ON tblAuthor.Author_ID = tblThread.Author_ID) ON tblTopic.Topic_ID = tblThread.Topic_ID " strSQL = strSQL & "ORDER BY tblThread.Message_date DESC;" 'Set the cursor type property of the record set to forward only so we can navigate through the record set rsThread.CursorType = 1 'Query the database rsThread.Open strSQL, strCon 'Loop round to read in all the forums in the database Do While NOT rsForum.EOF 'Initialise variables lngNumberOfTopics = Null lngNumberOfPosts = Null 'Read in forum details from the database intForumID = CInt(rsForum("Forum_ID")) strForumName = rsForum("Forum_name") strForumDiscription = rsForum("Forum_description") dtmForumStartDate = CDate(rsForum("Date_Started")) 'Initilaise variables for the information required for each forum dtmLastEntryDate = dtmForumStartDate strLastEntryUser = "Forum Adminstrator" lngLastEntryUserID = 1 'Filter the Topic Count recordset to only have the Topic count for the forum we are getting the details for rsTopicCount.Filter = "Forum_ID =" & intForumID 'If there are Topics in the database for the forum then loop through the record set to get the number of replies topics and replies for the forum If NOT rsTopicCount.EOF Then 'Read in the number of Topics lngNumberOfTopics = CLng(rsTopicCount("Topic_Count")) 'Filter the Thread detals recordset so we only have the thread detals for the forum we need the detals on rsThread.Filter = "Forum_ID =" & intForumID 'If there are threads for topic then read in the date and author of the last entry If NOT rsThread.EOF Then 'Read in the deatils from the recorset lngNumberOfPosts = CLng(rsThread.RecordCount) dtmLastEntryDate = CDate(rsThread("Message_date")) strLastEntryUser = Server.HTMLEncode(rsThread("Username")) lngLastEntryUserID = CLng(rsThread("Author_ID")) End If End If 'Write the HTML of the forum descriptions and hyperlinks to the forums %> <% 'Move to the next database record rsForum.MoveNext Loop End If 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing Set rsForum = Nothing Set rsTopicCount = Nothing Set rsThread = Nothing %>
Forum Topics Posts Last Post
There are no Forum's to display
<% = strForumName %>
<% = strForumDiscription %>
<% = lngNumberOfTopics %> <% = lngNumberOfPosts %> <% = FormatDateTime(dtmLastEntryDate, VbLongDate) %> at <% = FormatDateTime(dtmLastEntryDate, VbShortTime) %>
<% = strLastEntryUser %>

Cookies and JavaSctipt must be enabled on your web browser in order to use this forum


 

Copy Right 2001 www.thaichain.com  Email to me