Classifieds on Portal.asp - Postet den (1380 Views)
Starting Member
ejm3
Innlegg: 4
4
I have the classifieds mod and the portal mod installed. The classifieds only have 1 link in the site navigation and no way to show if a new one has been added.
I put together the following sub (mainly copied and pasted from the previous sub) so the latest classifieds show up on my portal.asp page.
Only the stuff between '##########My Additions##########:

Code:

sub DisplayActiveTopics(byval Width, byval Count)

dim strSql
dim rsActive

Call StartTable(Width, "Active Topics")

strSql = "SELECT"
strSql = strSql & " T.TOPIC_ID,"
strSql = strSql & " T.T_SUBJECT"
strSql = strSql & " FROM " & strTablePrefix & "TOPICS T," & strTablePrefix & "FORUM F"
strSql = strSql & " WHERE T.FORUM_ID = F.FORUM_ID"
strSql = strSql & " AND F.F_PRIVATEFORUMS = 0"
strSql = strSql & " AND T.T_STATUS = 1"
strSql = strSql & " ORDER BY T_LAST_POST DESC"

Set rsActive = my_conn.Execute(TopSQL(strSql, Count))
If NOT rsActive.EOF Then
Do While NOT rsActive.EOF

Response.Write("<a href=""topic.asp?TOPIC_ID="& rsActive.fields("TOPIC_ID").value &""">"& rsActive.fields("T_SUBJECT").value & "</a><br><br>")

rsActive.MoveNext
Loop
End If
rsActive.Close
Set rsActive = Nothing

Response.Write " <a href=""active.asp"">more active topics</a>" &vbCrLf

Call EndTable()

end sub

'##########My Additions##########
sub DisplayClassifieds(byval Width, byval Count)

Call StartTable(Width, "Classifieds")

dim rsAds
dim strClassSql

set rsAds = server.CreateObject("adodb.recordset")

'get the ads for this category
strClassSql = "Select ID, ad_title, city,"
strClassSql = strClassSql & "link FROM " & strTablePrefix & "ADS_CONTENT ORDER BY date_posted desc"
strClassSql = TopSQL(strClassSql, Count)
Set rsAds = my_Conn.Execute(strClassSql)

If NOT rsAds.EOF Then
Do While NOT rsAds.EOF

Response.Write("<a href=""classdetail.asp?id="& rsAds("ID") &""">"& rsAds("ad_title") & "</a><br>")
Response.Write(rsAds("City") & "<br>")

rsAds.MoveNext
Loop
End If
rsAds.Close
Set rsAds = Nothing

Response.Write " <br><a href=""classifieds.asp"">more classifieds</a>" &vbCrLf

Call EndTable()

end sub
'##########My Additions##########

I am very new to coding and learning quite a bit by searching these forums. I was just hoping that someone could take a look at this and make sure it's not messed up. The code works, but I don't want to leave any loose ends or make my database vulnerable. I would also like to hear if my tabs (indents) are sloppy.
Thanks

PS - I don't know how to use the scroll boxes that others use here. If someone lets me know, I would appreciate it.
   
 Sidestørrelse 
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
I'm overdue for my pain meds and not thinking too clearly. I'll let someone else review your code.
As for the scroll code, it's simply scrollcode and / scrollcode. To list code properly within it (so it can be cut/pasted), use scrollcode followed by code, and end with / code followed by / scrollcode.
Postet den
Starting Member
ejm3
Innlegg: 4
4
Thanks Carefree, I fixed the scrollcode.
 
Du må legge inn en melding