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

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Last 5 Posts on Main Page...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

fatwillie
New Member

Canada
79 Posts

Posted - 26 March 2001 :  05:40:58  Show Profile  Visit fatwillie's Homepage  Send fatwillie an ICQ Message
I was not quite sure where to put this as it involves the main page of my website and not the forum itself. It does, however, use the tables in the snitz Database.

Basically I am using this code to call the last five topics mad in my forum to show up on the main page...


<%
ConnString = "DSN=XXXXXX;uid=XXXXXXX;pwd=XXXXXXX"
function getlast_topics(numdays)
set tConn= Server.CreateObject("ADODB.Connection")
tConn.Open ConnString

strSql = "SELECT TOP "&numdays&" T_AUTHOR,T_LAST_POST,T_LAST_POSTER,T_DATE,T_SUBJECT,TOPIC_ID,FORUM_ID,CAT_ID from FORUM_TOPICS order by T_LAST_POST DESC"
CColor=strForumCellColor
set rss = tConn.Execute (strSql)

do until rss.eof
tID=rss("TOPIC_ID")
tPOSTER=rss("T_LAST_POSTER")
tDATE=rss("T_DATE")
tSUBJECT=rss("T_SUBJECT")
strlast =strlast&"<tr><td onMouseOver=""this.style.background='#333333';"" onMouseOut=""this.style.background='#000000';"" style=""cursor: hand"" bgcolor=""#000000"" onClick=""window.location.href='/forum/link.asp?TOPIC_ID="&tID&"'"" height=""18"" class=""button"">" &vbcrlf
strlast =strlast&"<div align=""left"" class=""button (unavailable)""><font face=""Veranda, Arial, Helvetica, san-serif"" size=""1""><a href=""/forum/link.asp?TOPIC_ID="&tID&""" class=""button (unavailable)""><small>"&tSUBJECT&"</small></a></font></div>"&vbcrlf
strlast =strlast&"</td></tr>"&vbcrlf

rss.movenext
loop

rss.close
set rss=nothing
tConn.close
set tConn=nothing
getlast_topics=strlast
end function
%>


And I use this to form the actual table on my page...

<table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#660000">
<%=getlast_topics(5)%>
</table>




Now it all works fine, but I would like to expand on the idea and yes I know it looks like several other mods, but I wanna make this one a little better than what it is now.

Basically I would like to the author, date and a little bit of the text from the post to be viewed on the index page of my site... all in a nice little table...

If anyone wants to help me with this I would most grateful!!! My website gets 400,000 page views a month, maybe we could swap some advertising for some help with this code or maybe you can just help me for free, what ever works.

Thanks in advance.


Fatwillie's Forum

blackinwhite
Average Member

Turkey
657 Posts

Posted - 27 March 2001 :  08:40:34  Show Profile
how about access "db"s?

Go to Top of Page

fatwillie
New Member

Canada
79 Posts

Posted - 27 March 2001 :  08:54:08  Show Profile  Visit fatwillie's Homepage  Send fatwillie an ICQ Message
Should work with access, as long as you have a DSN for the DB...

Fatwillie's Forum
Go to Top of Page

blackinwhite
Average Member

Turkey
657 Posts

Posted - 27 March 2001 :  09:52:21  Show Profile
it worked. simple but an effective mod.

Go to Top of Page

fatwillie
New Member

Canada
79 Posts

Posted - 27 March 2001 :  10:38:30  Show Profile  Visit fatwillie's Homepage  Send fatwillie an ICQ Message
Any ideas on how to make it better?

Fatwillie's Forum
Go to Top of Page

Aznknight
Senior Member

USA
1373 Posts

Posted - 27 March 2001 :  13:03:18  Show Profile  Send Aznknight an AOL message  Send Aznknight an ICQ Message
Hi fatwillie,

I wanted to check out what your code looks like but got this error when I visited you site.

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'FORUM_MEMBERS'.

/forum/inc_functions.asp, line 648


- Alan
www.iamviet.com
Go to Top of Page

Kurt
Starting Member

30 Posts

Posted - 27 March 2001 :  21:11:05  Show Profile  Visit Kurt's Homepage
http://forum.snitz.com/forum/link.asp?TOPIC_ID=7174

I did something similar, but built on the idea.

Go to Top of Page

fatwillie
New Member

Canada
79 Posts

Posted - 28 March 2001 :  05:47:22  Show Profile  Visit fatwillie's Homepage  Send fatwillie an ICQ Message
Aznknight, everything is fixed up now so you can go check it out.

Fatwillie's Forum
Go to Top of Page

Chuck McB
Junior Member

WooYay
196 Posts

Posted - 08 April 2001 :  13:57:58  Show Profile  Visit Chuck McB's Homepage  Send Chuck McB an ICQ Message
An extra addition to this ignores posts from private forums..


<%
'''''''''''''''''''''''
'' Top 5 forum posts
'''''''''''''''''''''''
ConnString = server.createobject("ADODB.Connection")

function getlast_topics(numdays)
set tConn = Server.CreateObject("ADODB.Connection")
'''''''''''''''''''''''''''''''''''''
''Replace with your connection string
'''''''''''''''''''''''''''''''''''''
tConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("forum.mdb")

'''''''''''''''''''''''''''''''''''''
''Don't display if from private forum
'''''''''''''''''''''''''''''''''''''
set PrivateForum = tConn.Execute("select FORUM_ID from FORUM_FORUM where F_PRIVATEFORUMS = 6")
SQL = "SELECT TOP " & numdays & " * from FORUM_TOPICS WHERE "

do until PrivateForum.eof
SQL = SQL & "FORUM_ID <> " & PrivateForum("FORUM_ID") & " and "
PrivateForum.movenext
Loop

'''''''''''''''''
''Drop last 'and'
'''''''''''''''''
SQL = Left(SQL, Len(SQL)-4)
SQL = SQL & "order by T_LAST_POST DESC"

set NewPosts = tConn.Execute (SQL)


do until NewPosts.eof
set GetName = tConn.Execute ("SELECT M_NAME from FORUM_MEMBERS WHERE MEMBER_ID = " & NewPosts("T_LAST_POST_AUTHOR"))
set GetSubject = tConn.Execute ("SELECT F_SUBJECT from FORUM_FORUM WHERE FORUM_ID = " & NewPosts("FORUM_ID"))

strlast = strlast & "<a href=/forum/link.asp?TOPIC_ID=" & NewPosts("TOPIC_ID") & " target=new>" & NewPosts("T_SUBJECT") & "</a> by <b>" & GetName("M_NAME") & "</b> posted in <b>" & GetSubject("F_SUBJECT") & "</b><br>"

GetSubject.close
set GetSubject=nothing

GetName.close
set GetName=nothing
NewPosts.movenext
loop


NewPosts.close
set NewPosts=nothing
tConn.close
set tConn=nothing
getlast_topics=strlast
end function
%>

<h2>Last 5 forum posts</h2>

<%=getlast_topics(5)%>



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.99 seconds. Powered By: Snitz Forums 2000 Version 3.4.07