Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - MOD: Latest Forum Posts in Default.asp
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MOD: Latest Forum Posts in Default.asp

 Post Reply Post Reply Page  <1 3456>
Author
Pfeff View Drop Down
Newbie
Newbie


Joined: 17 October 2006
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pfeff Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2007 at 1:16am
There is one available for SQL Server, I haven't run across it that runs on mySQL.

http://forums.webwiz.net/forum_posts.asp?TID=19472&KW=latest+posts&PID=117937#117937

BOttom of page three refers to how to get it done with SQL Server.

If anyone has one for this mod, I'd be greatly appreciated!

Dan
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2007 at 10:53am
The "MSSQL Last 10 Posts" thread includes a version that runs on all 3 databases - Access, mySQL and MS-SQL. The query can be easily changed to select specific forums and the fields that you display in the preview table.
Back to Top
Pfeff View Drop Down
Newbie
Newbie


Joined: 17 October 2006
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pfeff Quote  Post ReplyReply Direct Link To This Post Posted: 01 February 2007 at 2:42am
Got it for certain forums.

<%

Dim LastLatestPostsDateTime
Dim LastLatestPostsDate
Dim LastLatestPostsTime
Dim intStyle
Dim strShtMess
Dim saryTop10
Dim intRows
Dim fld_Subject
Dim fld_Topic_ID
Dim fld_Views
Dim fld_Date
Dim fld_Author
Dim fld_Thread_Id
Dim fld_Message

'### Set intStyle to give the required output
'### 1 = Top 10 latest posts, regardless of which Topic they appear in (gives a true Top 10 posts, but some might share the same Topic)
'### 2 = Top l0 latest Topics that have been posted to (gives unique Topics).
intStyle=1

strSql = "SELECT "
if strDatabaseType <> "mySQL" then strSql = strSql & "TOP 10 "
strSql = strSql & "T.Subject, T.Topic_ID, T.No_of_views, Th.Message_date, Au.Username, Th.Thread_ID, Th.message " & _
        "FROM " & strDbTable & "Topic T" & strDBNoLock & " " & _
        "INNER JOIN (" & strDbTable & "Thread Th" & strDBNoLock & " INNER JOIN " & strDbTable & "Author Au" & strDBNoLock & " " & _
        "ON Th.Author_ID = Au.Author_ID) "
if intStyle=1 then      
    strSql = strSql & "ON T.Topic_ID = Th.Topic_ID "
else
    strSql = strSql & "ON T.Last_Thread_ID = Th.Thread_ID "
end if
'### In the next line 25 represents the forum number      
strSql = strSql & "WHERE T.Hide = 0 and T.Forum_ID = 25 " & _

        "ORDER By Th.Message_date DESC "
if strDatabaseType = "mySQL" then strSql = strSql & "LIMIT 10"

rsCommon.Open strSQL, adoCon
saryTop10 = rsCommon.GetRows()

'Clean up
Call closeDatabase()

intRows = UBound(saryTop10, 2)

fld_Subject = 0
fld_Topic_ID = 1
fld_Views = 2
fld_Date = 3
fld_Author = 4
fld_Thread_Id = 5
fld_Message = 6


Response.Write "<table cellspacing=""1"" cellpadding=""3"" class=""tableBorder"" align=""center"">" & vbNewline & _
"<tr class=""tableLedger"">" & vbNewline & _
" <td colspan=""5"">Most Recent Topics - <a href='http://forums.sportsrubes.com'>Go to Forums Now!</a></td>" & vbNewline & _
" </tr>" & vbNewline & _
"      <tr class=""tableSubLedger"">" & vbNewline & _
"        <td width=""25%"" align=""center"">Topic</td>" & vbNewline & _
"        <td width=""33%"" align=""center"">Message</td>" & vbNewline & _
"        <td width=""15%"" align=""center"">Author</td>" & vbNewline & _
"        <td width=""20%"" align=""center"">Date</td>" & vbNewline & _
"        <td width=""7%"" align=""center"">Views</td></tr>" & vbNewline

If intRows=0 Then
    Response.Write "<tr class=""tableRow""><td colspan=5>No recent posts. Please check back later.</td></tr>" & vbNewline
Else
   for i = 0 to intRows
        LastLatestPostsDateTime = cDate(saryTop10(fld_Date,i))
        LastLatestPostsDate = DateFormat(LastLatestPostsDateTime)
        LastLatestPostsTime = TimeFormat(LastLatestPostsDateTime)
        strShtMess = left(saryTop10(fld_Message,i),40) & "..."
        Response.Write vbCrLf & " <tr "
        If (i MOD 2 = 0 ) Then Response.Write("class=""evenTableRow"">") Else Response.Write("class=""oddTableRow"">")   
        Response.Write("<td>")
        Response.Write "<a class=""smLink"" href=""" & strForumPath & "/forum_posts.asp?TID=" & CLng(saryTop10(fld_Topic_ID,i)) & "&get=last#" & saryTop10(fld_Thread_ID,i) & """ title="""">" & saryTop10(fld_Subject,i) & "</a></td>" & _
        "<td><span class=""smText"">" & strShtMess & "</span></td>" & _
        "<td align=""center""><span class=""smText"">" & saryTop10(fld_Author,i) &"</span></td>" & _
        "<td align=""center""><span class=""smText"">" & LastLatestPostsDate & "-" & LastLatestPostsTime & "</span></td>" & _
        "<td align=""center""><span class=""smText"">" & saryTop10(fld_Views,i) & "</span></td></tr>"
    next
end if

Response.Write "</table>"
%>

Thanks Brian for figuring this out!


Edited by Pfeff - 03 February 2007 at 3:05pm
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2007 at 10:07am
Pfeff, you don't need to include the Forum_ID field in the selected fields just because it's now in the WHERE clause.

strSql = strSql & "T.Subject, T.Topic_ID, T.Forum_ID, T.No_of_views, Th.Message_date, Au.Username, Th.Thread_ID, Th.message " & _

can stay as:

strSql = strSql & "T.Subject, T.Topic_ID, T.No_of_views, Th.Message_date, Au.Username, Th.Thread_ID, Th.message " & _


Back to Top
Pfeff View Drop Down
Newbie
Newbie


Joined: 17 October 2006
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pfeff Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 12:28am
Too sweet! I love learning. Thanks again!
Back to Top
Pfeff View Drop Down
Newbie
Newbie


Joined: 17 October 2006
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pfeff Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 12:30am
Is it possible to include posts from category ID?

I have a forum about sports. I have a category on hunting. I have 8 hunting subforums.

On the hunting index page I want to include the top 10 posts from the hunting category.


Edited by Pfeff - 03 February 2007 at 12:35am
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 2:35pm
Don't see why it can't be done. I've just been doing a big cleanup of the code (which I'll put in a new thread as it's changed a fair bit) so I'll take a look at categories as well.
Back to Top
Pfeff View Drop Down
Newbie
Newbie


Joined: 17 October 2006
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pfeff Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 2:39pm
Thanks bud!
Back to Top
 Post Reply Post Reply Page  <1 3456>

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.