Print Page | Close Window

Latest Individual Forum Posts

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21398
Printed Date: 29 March 2026 at 12:51pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Latest Individual Forum Posts
Posted By: balearicjobs
Subject: Latest Individual Forum Posts
Date Posted: 25 September 2006 at 8:24pm
Hi, I have a working script to place the latest forum posts on my front page for my entire forum which I enclose below. However I was wondering if it was possible to show the latest posts from one particular forum within my board. My website is a job website and one of the forums is the latest vacancies, I would like the abality to have my "Latest Job Vacancies" appear on the front page without the posts from my other forums. Is this possible.

Here is the code I currently use to display posts on my front page at the moment;


  <%
'#########################################################################
'##
'## Display Newest Forum Posts with WebWizForums v8.x
'##
'## Just configure the database settings and it will read the latest forum
'## posts. This file should be setup for your website.
'##
'## Mod from www.iportalx.net
'##
'## Writen by Drew Gauderman (aka MadDog)
'## Email: drew@aspinvision.com
'## Website: www.iportalx.net
'##
'## Dont want to do this yourself? Get iPortalX! A Portal with WebWizForum!
'## http://www.iportalx.net
'##
'#########################################################################
Dim rsCommon
Dim adoCon
Dim strCon
Dim strSQL
Dim strLastestPostsModTopicSubject
Dim strLastestPostsModForumPath
Dim intLastestPostsTotal
Dim strDatabaseType
Dim strDBTrue
Dim strDBFalse
Dim strFrameTarget
'The path to the forum
strForumPath = "http://www.balearic-jobs.com/asp/mb/"
'How many new topics to show
intLastestPostsTotal = 15
'//-----------------------------------------------------
'// Database connection and settings
'//-----------------------------------------------------
'Database settings for Access
strDatabaseType = "Access"
strDBTrue = "True"
strDBFalse = "False"
'Database settings for MSSQL
'strDatabaseType = "SQLServer"
'strDBTrue = "1"
'strDBFalse = "0"
'Database settings for MySQL
'strDatabaseType = "MySQL"
'strDBFalse = 0
'strDBTrue = -1
'Access connection
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("<snip>.mdb")  'This one is for Access 2000/2002

'MSSQL Connection
'Const strSQLServerName = ".\SQLExpress" 'Holds the name of the SQL Server (This is the name/location or IP address of the SQL Server)
'Const strSQLDBUserName = "sa" 'Holds the user name (for SQL Server Authentication)
'Const strSQLDBPassword = "blank" 'Holds the password (for SQL Server Authentication)
'Const strSQLDBName = "beta2"
'strCon = "Provider=SQLOLEDB;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
'//-----------------------------------------------------
'Start the database connection
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open strCon
'Start a recordset connection
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then strSQL = strSQL & " TOP " & intLastestPostsTotal & " "
strSQL = strSQL & "tblForum.Forum_name, tblTopic.Topic_ID, tblTopic.Subject, tblThread.Thread_ID, tblThread.Message_date, tblAuthor.Author_ID, tblAuthor.Username, tblThread.Message  " & _
    "FROM tblForum, tblTopic, tblAuthor, tblThread, tblPermissions " & _
    "WHERE tblForum.Forum_ID = tblTopic.Forum_ID " & _
        "AND tblTopic.Topic_ID = tblThread.Topic_ID " & _
        "AND tblAuthor.Author_ID = tblThread.Author_ID " & _
        "AND tblForum.Forum_ID = tblPermissions.Forum_ID " & _
        "AND (tblPermissions.Group_ID = 2 AND tblPermissions.View_Forum = " & strDBTrue & ") "
strSQL = strSQL & "AND (tblForum.Password = '' OR tblForum.Password Is Null) AND (tblTopic.Hide = " & strDBFalse & " AND tblThread.Hide = " & strDBFalse & ") ORDER BY tblThread.Message_date DESC "
'mySQL limit operator
If strDatabaseType = "mySQL" Then strSQL = strSQL & " LIMIT " & intLastestPostsTotal
strSQL = strSQL & ";"
rsCommon.Open strSQL, adoCon
If NOT rsCommon.EOF Then saryForumPosts = rsCommon.getRows()
'Close all connections, very important!!
rsCommon.Close
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
 
'No forum posts
If IsArray(saryForumPosts) = False Then
    Response.Write "<span class=""text_arial"">No Forum Posts Made</span>"
'Forum posts have been made
Else
    'Loop through the array of forum posts
    For intLoopCounter = 0 TO UBound(saryForumPosts, 2)
        'saryForumPosts array lookup table
        '0 = tblForum.Forum_name
        '1 = tblTopic.Topic_ID
        '2 = tblTopic.Subject
        '3 = tblThread.Thread_ID
        '4 = tblThread.Message_date
        '5 = tblAuthor.Author_ID
        '6 = tblAuthor.Username
        '7 = tblThread.Message
        strLastestPostsModTopicSubject = saryForumPosts(2, intLoopCounter)
        'Crop the subject down to 18 characters
        If Len(strLastestPostsModTopicSubject) > 18 then strLastestPostsModTopicSubject = Left(strLastestPostsModTopicSubject,30) & "..."
        Response.Write("<li><a href=""" & strForumPath & "forum_posts.asp?TID=" & saryForumPosts(1, intLoopCounter) & """ target=""_top"">" & strLastestPostsModTopicSubject & "</a></li>")
    Next
End If
%></td>
  </tr> </table> </font> </p>



-------------
Thanks for your help!!!
Kind Regards
Rob,
http://www.balearic-jobs.com" rel="nofollow - Balearic Jobs
Helping young people find seasonal work in the Balearic Islands, including vacancie



Replies:
Posted By: balearicjobs
Date Posted: 25 September 2006 at 8:27pm
Just a quick side line. The above script currently displays the title of the post everytime a new reply is added, for example if I was too create a post titled "Test", it would appear as following;

- Test
- Another Post
- And Another

however if I or somebody else replies it displays

- Test
- Test
- Another Post

Is it possible to modify the script to only display the post once within the list even when the thread is updated?

Thank you for all your help!


-------------
Thanks for your help!!!
Kind Regards
Rob,
http://www.balearic-jobs.com" rel="nofollow - Balearic Jobs
Helping young people find seasonal work in the Balearic Islands, including vacancie


Posted By: Hades
Date Posted: 26 September 2006 at 9:14pm

For the first question, you could add

WHERE tblForum.Forum_ID = 1
("1" being the forum you want to display..)
Somewhere in the SQL query (sorry, didn't analyse it all ;)
 
And the second, you could use the "DISTINCT" statement.. but I guess you already tried these two simple ideas..


-------------
Hades[hLcYb¿]

-What're quantum mechanics?
-I don't know. People who repair quantums, I suppose.

--Rincewind, Discworld


Posted By: balearicjobs
Date Posted: 27 September 2006 at 1:49pm
Originally posted by Hades Hades wrote:

For the first question, you could add

WHERE tblForum.Forum_ID = 1
("1" being the forum you want to display..)
Somewhere in the SQL query (sorry, didn't analyse it all ;)
 
And the second, you could use the "DISTINCT" statement.. but I guess you already tried these two simple ideas..


An answer is on simple if you know the answer. Wink Unfortunetly know so little about ASP that that idea had not occured to me. I'll try messing around with that Forum_ID=1 to see if I can get the correct forum to appear. Thank you.

Any additional ideas would be appreciated.





Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net