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)
 help me to improve this code
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ez4arab
Junior Member

479 Posts

Posted - 15 November 2003 :  21:13:37  Show Profile  Visit Ez4arab's Homepage
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

Posted - 17 November 2003 :  06:33:13  Show Profile  Visit Ez4arab's Homepage
no one can help

Ez4arab web site Ez4arab |
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 17 November 2003 :  12:48:18  Show Profile
why do you want to put the code in red there? I'm afraid that I don't understand what you want to do.
Go to Top of Page

Ez4arab
Junior Member

479 Posts

Posted - 17 November 2003 :  15:10:08  Show Profile  Visit Ez4arab's Homepage
because i do not want to show the privte forums. also i want to add 3X12 table

Ez4arab web site Ez4arab |
Go to Top of Page

snaayk
Senior Member

USA
1061 Posts

Posted - 17 November 2003 :  15:16:04  Show Profile  Visit snaayk's Homepage  Send snaayk an AOL message  Send snaayk an ICQ Message  Send snaayk a Yahoo! Message
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.

Go to Top of Page

Ez4arab
Junior Member

479 Posts

Posted - 18 November 2003 :  16:56:42  Show Profile  Visit Ez4arab's Homepage
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 |
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 19 November 2003 :  01:08:55  Show Profile
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
Go to Top of Page

Ez4arab
Junior Member

479 Posts

Posted - 24 November 2003 :  22:29:36  Show Profile  Visit Ez4arab's Homepage
yes i have many forums i like to show some of them. is it possible to use forum_id

Ez4arab web site Ez4arab |
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 25 November 2003 :  02:47:45  Show Profile
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
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