Author |
Topic |
|
Ez4arab
Junior Member
479 Posts |
Posted - 15 November 2003 : 21:13:37
|
Any one can help me to improve this code. I want to display forum title, post and replay numbers. I came up with this code.
I highlighted with red what I want to improve i don't want to repeat sentence more then 20 sentences also I want to include them in table. Is possible to use select case?
'## Forum_SQL - Build SQL to get forums
strSql = "SELECT F.FORUM_ID, F.F_STATUS, F.F_SUBJECT, F.F_TOPICS, " &_
"F.F_COUNT " & _
"FROM " & strTablePrefix & "FORUM F " '& _
'"Where F_STATUS=1 "
'strSQL = strSQL & "ORDER BY FORUM_ID DESC;"
set rsForum = Server.CreateObject("ADODB.Recordset")
rsForum.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if rsForum.EOF then
recForumCount = ""
else
allForumData = rsForum.GetRows(adGetRowsRest)
recForumCount = UBound(allForumData,2)
end if
rsForum.close
set rsForum = nothing
If recForumCount = "" then
'donothing
else
fFORUM_ID = 0
fF_SUBJECT = 1
fF_TOPICS = 2
fF_COUNT = 3
for iForum = 0 to recForumCount
ForumID = allForumData(fFORUM_ID,iForum)
ForumSubject = allForumData(fF_SUBJECT,iForum)
ForumTopics = allForumData(fF_TOPICS,iForum)
ForumCount = allForumData(fF_COUNT,iForum)
if ForumID = 4 then
Call DisplayForum()
end if
next
end if
sub displayForum
Response.Write "" & vbNewLine
Response.Write "<br />-----<br>"
Response.Write "<br />Forum id" & ForumID &_
"<br />Topic post " & ForumTopics &_
"<br />Reply post " & ForumCount &_
"<br />Fourm tital" & ForumSubject
end sub
Example
|
Ez4arab web site Ez4arab | |
|
Ez4arab
Junior Member
479 Posts |
|
bjlt
Senior Member
1144 Posts |
Posted - 17 November 2003 : 12:48:18
|
why do you want to put the code in red there? I'm afraid that I don't understand what you want to do. |
|
|
Ez4arab
Junior Member
479 Posts |
Posted - 17 November 2003 : 15:10:08
|
because i do not want to show the privte forums. also i want to add 3X12 table |
Ez4arab web site Ez4arab | |
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 17 November 2003 : 15:16:04
|
If you only want to display those records that are forum_if = 4 then why not place that particular code in your SQL? Such as:
'## Forum_SQL - Build SQL to get forums
strSql = "SELECT F.FORUM_ID, F.F_STATUS, F.F_SUBJECT, F.F_TOPICS, " &_
"F.F_COUNT " & _
"FROM " & strTablePrefix & "FORUM F " '& _
'"Where F_STATUS=1 AND F.FORUM_ID = 4 "
'strSQL = strSQL & "ORDER BY FORUM_ID DESC;"
This way only the records you want will be shown and there is no need for the if statement.
|
|
|
Ez4arab
Junior Member
479 Posts |
Posted - 18 November 2003 : 16:56:42
|
quote: Originally posted by snaayk
If you only want to display those records that are forum_if = 4 then why not place that particular code in your SQL? Such as:
'## Forum_SQL - Build SQL to get forums
strSql = "SELECT F.FORUM_ID, F.F_STATUS, F.F_SUBJECT, F.F_TOPICS, " &_
"F.F_COUNT " & _
"FROM " & strTablePrefix & "FORUM F " '& _
'"Where F_STATUS=1 AND F.FORUM_ID = 4 "
'strSQL = strSQL & "ORDER BY FORUM_ID DESC;"
This way only the records you want will be shown and there is no need for the if statement.
thanx for help i have many record not noly one forum what i put just ex |
Ez4arab web site Ez4arab | |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 19 November 2003 : 01:08:55
|
do you mean you want to select many forums, e.g. forum_id = 1, 2, 3, 4, 7 ... etc? and you may add more forums to the list later when you change the property of a forum or add a new one?
if so, what's the uniqueness of these forums in comparison with others? do they have a field to identify themselves from others? if there's such a field you can just put the field=value in the select sql statement
'"Where F_STATUS=1 AND F.FIELDNAME = VALUE-MARKING-THEM-UNIQUE "
'strSQL = strSQL & "ORDER BY FORUM_ID DESC;"
|
Edited by - bjlt on 19 November 2003 01:09:36 |
|
|
Ez4arab
Junior Member
479 Posts |
Posted - 24 November 2003 : 22:29:36
|
yes i have many forums i like to show some of them. is it possible to use forum_id |
Ez4arab web site Ez4arab | |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 25 November 2003 : 02:47:45
|
Are there any fields identify them from others? e.g. F_PRIVATE = 'TRUE', or F_SHOWIT = 1? If there're such fields, just put them in the 'where' clause.
If there'are no such fields, either creat one for them, or if there are not too many of forums you want to show, and you don't change them often, you can use 'where ... AND FORUM_ID IN (1,2,3,4,5)' (comma deliminated forum_id's you want to show) |
Edited by - bjlt on 25 November 2003 02:52:52 |
|
|
|
Topic |
|