Author |
Topic |
|
eggyfarts
Junior Member
New Zealand
200 Posts |
Posted - 05 December 2002 : 05:14:03
|
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
|
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 |
|
|
eggyfarts
Junior Member
New Zealand
200 Posts |
Posted - 05 December 2002 : 06:39:08
|
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.
|
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 05 December 2002 : 07:41:52
|
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. |
|
|
David K
Junior Member
494 Posts |
Posted - 05 December 2002 : 13:37:56
|
don't forget to end the if statemant |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 05 December 2002 : 13:54:18
|
actually there are two which need ending, but I did say it wasn't perfect |
|
|
eggyfarts
Junior Member
New Zealand
200 Posts |
Posted - 05 December 2002 : 15:19:47
|
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.
|
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 05 December 2002 : 15:40:02
|
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. |
|
|
eggyfarts
Junior Member
New Zealand
200 Posts |
Posted - 05 December 2002 : 15:44:32
|
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.
|
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 05 December 2002 : 16:01:22
|
wow, what an odd error message
ad this just below the strSQL= line
set rsRank = Server.CreateObject("ADODB.Recordset") |
|
|
ferixo
Starting Member
Italy
4 Posts |
Posted - 05 December 2002 : 16:02:34
|
Non ci capisco niente. |
FERIXO |
|
|
|
Topic |
|