Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Including "last 5 posts" on my homepage
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Zenfor
Junior Member

372 Posts

Posted - 11 October 2002 :  06:58:37  Show Profile
I'm sure this has come up but can't put my fingers on an answer and would appreciate a little help.

Just so I'm clear.

I want to "include" the last 5 or so posts that were posted on my forum into an area on my homepage. You see this on some of the portal mods.

Appreciate any help.

Edited by - ruirib on 13 October 2002 14:39:15

RichardNHurt
Starting Member

USA
1 Posts

Posted - 11 October 2002 :  07:47:53  Show Profile  Visit RichardNHurt's Homepage  Send RichardNHurt an AOL message  Send RichardNHurt a Yahoo! Message
I just did this on our Portal. Below is the code. It's not pretty but it will give you something to begin with.

============================= SNIP ===================================

<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_func_common.asp"-->

<%
Function TrimString(strString, intLength)
strString = Replace(strString, vbCrLf, "")
If Len(strString) > intLength Then
strString = Left(strString, intLength)
aryString = Split(strString, " ")
strString = ""
For a = 0 to UBound(aryString)-1
strString = strString & " " & aryString(a)
Next
strString = Trim(strString)
strString = strString & " ..."
End If
TrimString = strString
End Function
%>

<%
'-------------------------------------------
' Hardcode some values
'-------------------------------------------
intMaxSubjectLine = 45

'-------------------------------------------
' Get some variables
'-------------------------------------------
if (Request("FORUM_ID") = "" or IsNumeric(Request("FORUM_ID")) = False) then
intForumNumber = 2
else
intForumNumber = Request("FORUM_ID")
end if

if (Request("TOP_MSGS") = "" or IsNumeric(Request("TOP_MSGS")) = False) then
intMaxNumberOfMessages = 5
else
intMaxNumberOfMessages = Request("TOP_MSGS")
end if

'-------------------------------------------
' Get a connection to the database
'-------------------------------------------
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Open strConnString

'-------------------------------------------
' Select the TOPICS we need
'-------------------------------------------
strSQL = "SELECT TOP " & intMaxNumberOfMessages _
& "MEMBERS.M_NAME, " _
& "FORUM.FORUM_ID, " _
& "FORUM.F_SUBJECT, " _
& "TOPICS.TOPIC_ID, " _
& "TOPICS.T_SUBJECT, " _
& "TOPICS.T_AUTHOR, " _
& "TOPICS.T_REPLIES, " _
& "TOPICS.T_DATE, " _
& "TOPICS.T_LAST_POST, " _
& "TOPICS.T_MESSAGE " _
& "FROM FORUM_TOPICS TOPICS, FORUM_FORUM FORUM, FORUM_MEMBERS MEMBERS " _
& "WHERE FORUM.F_PRIVATEFORUMS = 0 AND " _
& "FORUM.FORUM_ID = " & intForumNumber & " AND " _
& "TOPICS.FORUM_ID = FORUM.FORUM_ID AND " _
& "TOPICS.T_AUTHOR = MEMBERS.MEMBER_ID " _
& "ORDER BY TOPICS.T_LAST_POST desc"

set rsInfo = my_Conn.Execute (StrSql)

'-------------------------------------------
' Loop through the TOPICS
'-------------------------------------------
While NOT rsInfo.EOF
strXML = strXML & VbCrLf _
& "<a href = '/topic.asp?TOPIC_ID=" & rsInfo("topic_id") & "'>" _
& TrimString(rsInfo("t_subject"), intMaxSubjectLine) & "</a>" & VbCrLf _
& " - " & rsInfo("M_name") & VbCrLf _
& " - " & chkDate(rsInfo("T_LAST_POST"), , False) & VbCrLf _
& chkTime(rsInfo("T_LAST_POST"))& VbCrLf _
& "<br />"
rsInfo.MoveNext
Wend

'-------------------------------------------
' Clean up
'-------------------------------------------
my_Conn.Close
Set my_Conn = Nothing
Set rsInfo = NOthing
%>

<span style="font-size: smaller"><%=strXML%></span>

Later...
  Richard
Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 11 October 2002 :  07:49:34  Show Profile  Visit Kat's Homepage
There is a slash mod somewhere that does what you are asking - not the marquee though. Try looking at snitzbitz.com.

KatsKorner

Installation Help | Snitz Mods | Forum Hosting
Go to Top of Page

Zenfor
Junior Member

372 Posts

Posted - 13 October 2002 :  13:02:42  Show Profile
Richard,

Thanks for the info.

I tried this on a test page and I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.

/test1.asp, line 77

LINE 77 looks like this:
set rsInfo = my_Conn.Execute (StrSql)

Appreciate any ideas.
Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 14 October 2002 :  05:43:39  Show Profile  Visit Kat's Homepage
You will need to print out the contents of StrSql to see what is wrong.

KatsKorner

Installation Help | Snitz Mods | Forum Hosting
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07