Någon som kan hjälpa mig?
Hej
Håller på och trixar med en "senaste inlägget" funktion.
Koden jag har idag ser ut så här, och den hämtar senaste tråden som är postad, men jag vill att den ska lista senaste tråden som någon har skrivit i.
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("fo.mdb")
'//Converts UNIX timestamps into the format the current webserver use.
Function uTimeStamp(byval dDate) '// Bring the date back from database and show in current session.LCID
on error resume next
uTimeStamp = DateAdd("s", dDate, "01/01/1970 00:00:00")
if err then
cTimeStamp = int(0)
end if
End Function
dim strSQL
strSQL = "SELECT TOP 10 * FROM aspbb_topics WHERE tforumid=6 ORDER BY tdatecreate DESC" 'Change tforumid=30 to the id of your newsthread
set objNews = objConn.Execute(strSQL)
set objRegExp = new regexp
objRegExp.global = true
objRegExp.pattern = "\[img=([^\]]+)\]"
Do Until objNews.EOF
Response.Write "<p><div class=""aspbbcolormain"">" & objNews("ttitle") & " - " & uTimeStamp(objNews("tdatecreate")) & "</div><br/>" & vbNewLine
strText = Replace(objNews("tbody"), vbcrlf, "<br/>") & "<br/>"
strText = objRegExp.replace(strText,"<img border=""0"" src=""$1""><br/>")
response.write strText
Response.write "<div style=""text-align:right""><a href=""topic.asp?TID=" & objNews("tid") & """>Läs</a></div>" & vbNewLine
Response.Write "<br/></p>" & vbNewLine
objNews.MoveNext
Loop
set objRegExp = nothing
objNews.Close : Set objNews = Nothing
objConn.Close : Set objConn = Nothing
%>
I självaste forumet finns denna funktionen men det är en fristående sida jag håller på med så det är inte mycket till hjälp.
Men koden som finns i forumet ser ut så här.
<%
LanguageParser.IncludeSection "latestposts"
%>
<span class="Stort"><%= langLatestPost %>: (<%=intDisplayThreads%>)</span>
<table width="<%=strTable%>" align="<%=strAlign%>" border="0" cellspacing="1" cellpadding="4" class="aspbbmain">
<tr class="aspbbcolormain">
<td class="aspbbcolormain"><% =langThread %></td>
<td class="aspbbcolormain" width="120"><center><% =langAuthor %></center></td>
<td class="aspbbcolormain" width="120"><center><% =langLastPost %></center></td>
<td width="70" class="aspbbcolormain"><center><% =langReplies %></center></td>
<td width="70" class="aspbbcolormain"><center><% =langViews %></center></td>
</tr>
<%
dim arrForum, x, strLastPoster, arrLastPoster, strLastPosterId, postid, arrTempCategories, accessedSubs
'/// Our SQL query
if IsAdmin(userId) Then
strSQL = "SELECT aspbb_topics.ttitle, aspbb_topics.ttype, aspbb_topics.tanswers, aspbb_topics.tseen, aspbb_topics.tid, aspbb_topics.tpoll, aspbb_topics.tbody, aspbb_members.mid, aspbb_members.muser " & _
"FROM aspbb_topics INNER JOIN aspbb_members ON aspbb_topics.tmemberid = aspbb_members.mid " & _
"WHERE ((aspbb_topics.ttype = 0 AND aspbb_topics.tshow = 1 AND aspbb_topics.toldid = 0) OR (aspbb_topics.ttype = 2 AND aspbb_topics.tshow = 1 AND aspbb_topics.toldid = 0)) ORDER BY aspbb_topics.tdatelast DESC"
Else
strSQL = "Select sid from aspbb_subcategory"
objDAL.Open arrTempCategories, strSQL, Empty
if not EOF(arrTempCategories) Then
for i = 0 to UBound(arrTempCategories, 2)
if AccessSub(userid, arrTempCategories(0, i)) Then
if accessedSubs <> "" then accessedSubs = accessedSubs & ","
accessedSubs = accessedSubs & "" & arrTempCategories(0, i) & ""
End if
Next
else
accessedSubs = 0
End if
strSQL = "SELECT aspbb_topics.ttitle, aspbb_topics.ttype, aspbb_topics.tanswers, aspbb_topics.tseen, aspbb_topics.tid, aspbb_topics.tpoll, aspbb_topics.tbody, aspbb_members.mid, aspbb_members.muser " & _
"FROM aspbb_topics INNER JOIN aspbb_members ON aspbb_topics.tmemberid = aspbb_members.mid " & _
"WHERE (((aspbb_topics.ttype = 0 AND aspbb_topics.tshow = 1 AND aspbb_topics.toldid = 0) OR (aspbb_topics.ttype = 2 AND aspbb_topics.tshow = 1 AND aspbb_topics.toldid = 0))"
if len(accessedSubs) > 0 Then
strSQL = strSQL & " AND aspbb_topics.tforumid in(" & accessedSubs & "))"
Else
strSQL = strSQL & " AND aspbb_topics.tforumid in(" & 0 & "))"
End if
strSQL = strSQL & " ORDER BY aspbb_topics.tdatelast DESC"
End if
objDAL.GetRows arrForum, intDisplayThreads, strSQL, empty
if not EOF(arrForum) then
for i = 0 to UBound(arrForum, 2)
'// Last post was made by?
strLastPoster = "-"
strSQL = "Select aspbb_members.muser,aspbb_members.mid, aspbb_posts.pid FROM aspbb_posts INNER JOIN aspbb_members ON aspbb_members.mid=aspbb_posts.pmemberid WHERE aspbb_posts.ptopicid= {0} ORDER BY aspbb_posts.pdatecreate DESC"
objDAL.GetRows arrLastPoster, 1, strSQL, Array(arrForum(4, i))
If Not EOF(arrLastPoster) Then
strLastPoster = arrLastPoster(0, 0)
strLastPosterId = arrLastPoster(1, 0)
postid = arrLastPoster(2,0)
End if
'//Check if this is an administrative part of the forum
If arrForum(1, i) = 0 or arrForum(1, i) = 2 then
if x mod 2 then
dim mouseover
if blnThirdColor then
mouseover = " onmouseover=""this.className='aspbbcolor3'"" onmouseout=""this.className='aspbbcolor1'"""
end if
%>
<tr class="aspbbcolor1"<%=mouseover%>>
<td>
<%if arrForum(1, i) = 2 then
response.write("<span class=""stort"">"& langSticky &": </span>")
End if
If arrForum(5, i) <> 0 then
Response.Write("<span class=""stort"">"& langPoll &": </span>")
End if%>
<a href="topic.asp?COMMAND=GOTOLAST&TID=<%=arrForum(4, i)%>#<%=postid%>"><%=Server.HTMLEncode(arrForum(0, i))%></a>
</td>
<td class="center"><a href="profile.asp?PROFILE_ID=<%=arrForum(7, i)%>"><%=arrForum(8, i) %></a></td>
<td class="center">
<% If strLastPoster <> "-" then %>
<a href="profile.asp?PROFILE_ID=<%=strLastPosterId %>"><% =strLastPoster%></a>
<% Else %>
<% =strLastPoster%>
<% End if%>
</td>
<td class="center"><%=arrForum(2, i)%> </td>
<td class="center"><%=arrForum(3, i)%> </td>
</tr>
<% Else
if blnThirdColor then
mouseover = " onmouseover=""this.className='aspbbcolor3'"" onmouseout=""this.className='aspbbcolor2'"""
end if
%>
<tr class="aspbbcolor2"<%=mouseover%>>
<td>
<%if arrForum(1, i) = 2 then
response.write("<span class=""stort"">"& langSticky &": </span>")
End if
If arrForum(5, i) <> 0 then
Response.Write("<span class=""stort"">"& langPoll &": </span>")
End if%>
<a href="topic.asp?COMMAND=GOTOLAST&TID=<%=arrForum(4, i)%>#<%=postid%>"><%=Server.HTMLEncode(arrForum(0, i))%></a>
</td>
<td class="center"><a href="profile.asp?PROFILE_ID=<%=arrForum(7, i)%>"><%=arrForum(8, i) %></a></td>
<td class="center">
<% If strLastPoster <> "-" then %>
<a href="profile.asp?PROFILE_ID=<%=strLastPosterId %>"><% =strLastPoster%></a>
<% Else %>
<% =strLastPoster%>
<% End if%>
</td>
<td class="center"><%=arrForum(2, i)%> </td>
<td class="center"><%=arrForum(3, i)%> </td>
</tr>
<% End If
x = x + 1
Elseif arrForum(1, i) = 1 then 'Sticky announcment
%>
<tr class="aspbbcolor1">
<td class="aspbbcolor2" colspan="5"><strong><%=Server.HTMLEncode(arrForum(0, i))%></strong><br /><%=arrForum(6, i)%></td>
</tr>
<%
End if
Next
else
Response.write "<tr class=""aspbbmain1""><td width=""20""></td><td colspan=""5"" class=""aspbbmain1"">" & LanguageParser.GetKey("errors", "ErrorNoThreads") &"</td></tr>"
end if
%>
</table>
<br />
Och includerar jag denna koden så blir det helknas, men en massa felmeddelanden och så.
