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)
 Determine rank, posts/members
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 05 December 2002 :  05:14:03  Show Profile
Hi,

I am just trying to write a MOD where logged on users can see what rank they are as for posting, I just want to have a little text line of the main page somewhere saying something like: "You'r ranked 12 for posts".

Anyway what I would like to know is what would be the formula be for determining the rank, I am completely lost as to how to figure it out. My next question would be what kind of select statement would I use to get the rank, because I assume it will involve dividing and adding multiple times.

I have been sitting here with my calculator trying to figure this out (how to determine the rank) but I am at a loss as to how to do it.

BTW: By rank i mean as in top poster, IE the person with the most posts is ranked 1, person with 2nd most posts is ranked 2 and so on.

Cheers,
WeeVaa.

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  06:31:13  Show Profile  Visit HuwR's Homepage
since this is not stored any where, you will need to do something like this.

do a select and order it by m_posts DESC, then using getrows, retrieve it into an array.

You will now need to use a counter while you increment through the loop (don't update counter if post count is the same. Then when you get to the correct user, break out of the loop and display the counter value
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 05 December 2002 :  06:39:08  Show Profile
Wow, you make it seem so easy . I was with you during the "do a select and order it by m_posts DESC" bit, but lost you after the rest. If you wouldn't mind, could you explain this in a little more detail please. If you are too busy dont worry though.

Cheers,
WeeVaa.

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  07:41:52  Show Profile  Visit HuwR's Homepage
Ok, will try, but don't blame me if it isn't perfect


	strSQL = "SELECT MEMBER_ID,M_POSTS FROM FORUM_MEMBERS WHERE M_STATUS=1 ORDER BY M_POSTS DESC"	
	rsRank.Open strSQL, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
	rMember = 0
	rPosts = 1
	if not rsRank.eof then 
		arrRanking = rsRank.GetRows(adGetRowsRest)
		rsRank.Close
		Set rsRank= Nothing
		recCount = UBound(arrRanking ,2)
		if recCount <> "" then
		rankNo = 1
		lastRank = 0
		for i = 0 to recCount 
			if arrRanking(rPosts,i) <> lastRank then
				lastRank = arrRanking(rPosts,i)
				rankNo = rankNo + 1
			end if
			if arrRanking(rMember,i) = MemberID then Exit For
		Next

or something along those lines anyway.
Go to Top of Page

David K
Junior Member

494 Posts

Posted - 05 December 2002 :  13:37:56  Show Profile  Send David K an AOL message  Send David K an ICQ Message  Send David K a Yahoo! Message
don't forget to end the if statemant
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  13:54:18  Show Profile  Visit HuwR's Homepage
actually there are two which need ending, but I did say it wasn't perfect
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 05 December 2002 :  15:19:47  Show Profile
OK, this is was I tried to use, just to see if it would work. I just saved the file as test_rank.asp and uploaded it. When I executed it I got a server 500 error. Only prob is tht I cant red the error message (it's in another language). But here is my code anyway.


<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_functions.asp" -->
<!--#INCLUDE FILE="inc_top.asp" -->
<%
	strSQL = "SELECT MEMBER_ID,M_POSTS FROM PORTAL_MEMBERS WHERE M_STATUS=1 ORDER BY 

M_POSTS DESC"	
	rsRank.Open strSQL, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
	rMember = 0
	rPosts = 1
	if not rsRank.eof then 
		arrRanking = rsRank.GetRows(adGetRowsRest)
		rsRank.Close
		Set rsRank= Nothing
		recCount = UBound(arrRanking ,2)
		if recCount <> "" then
		rankNo = 1
		lastRank = 0
		for i = 0 to recCount 
			if arrRanking(rPosts,i) <> lastRank then
				lastRank = arrRanking(rPosts,i)
				rankNo = rankNo + 1
			end if
			if arrRanking(rMember,i) = MemberID then Exit For
		Next
		end if
	end if
%>
<!--#INCLUDE FILE="inc_footer.asp" -->


Is there something that needs to be changed in here? Thanks HuwR for you help

Cheers,
WeeVaa.

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  15:40:02  Show Profile  Visit HuwR's Homepage
the server 500 error is given by your browser, turn off friendly http error messages in advanced options. (of your browser)

I assumed you were using the latest release, if not you can't use any of thses variables
adOpenForwardOnly, adLockReadOnly, adCmdText unless you include a file.
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 05 December 2002 :  15:44:32  Show Profile
OK, I got a friend to test out the script on his server and the error message he got was this:


Microsoft VBScript runtime error '800a01a8' 

Object required: '' 

/test_rank.asp, line 6



The reason I cant see the error message on my server is because they set a custom error message up, but it doesn't execut properly, and I can't change it back. You can see what happens when I get an error message: www.arackspace.com/weevaa/test_rank.asp .

What is the file that I need to include. I am not using the latest version of snitz, I am using a modified portal system.

Cheers,
WeeVaa.

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  16:01:22  Show Profile  Visit HuwR's Homepage
wow, what an odd error message


ad this just below the strSQL= line

set rsRank = Server.CreateObject("ADODB.Recordset")
Go to Top of Page

ferixo
Starting Member

Italy
4 Posts

Posted - 05 December 2002 :  16:02:34  Show Profile
Non ci capisco niente.

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