| Author |
Topic Search Topic Options
|
Pfeff
Newbie
Joined: 17 October 2006
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
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#117937BOttom 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
|
 |
MrMellie
Senior Member
Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Pfeff
Newbie
Joined: 17 October 2006
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
MrMellie
Senior Member
Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
|
Post Options
Thanks(0)
Quote Reply
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 " & _
|
 |
Pfeff
Newbie
Joined: 17 October 2006
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
Posted: 03 February 2007 at 12:28am |
|
Too sweet! I love learning. Thanks again!
|
 |
Pfeff
Newbie
Joined: 17 October 2006
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
MrMellie
Senior Member
Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Pfeff
Newbie
Joined: 17 October 2006
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
Posted: 03 February 2007 at 2:39pm |
|
Thanks bud!
|
 |