Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Latest Individual Forum Posts
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Latest Individual Forum Posts

 Post Reply Post Reply
Author
balearicjobs View Drop Down
Groupie
Groupie
Avatar

Joined: 13 July 2002
Location: United Kingdom
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote balearicjobs Quote  Post ReplyReply Direct Link To This Post Topic: Latest Individual Forum Posts
    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,
Balearic Jobs
Helping young people find seasonal work in the Balearic Islands, including vacancie
Back to Top
balearicjobs View Drop Down
Groupie
Groupie
Avatar

Joined: 13 July 2002
Location: United Kingdom
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote balearicjobs Quote  Post ReplyReply Direct Link To This Post 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,
Balearic Jobs
Helping young people find seasonal work in the Balearic Islands, including vacancie
Back to Top
Hades View Drop Down
Newbie
Newbie


Joined: 17 January 2005
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hades Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
balearicjobs View Drop Down
Groupie
Groupie
Avatar

Joined: 13 July 2002
Location: United Kingdom
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote balearicjobs Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.