Print Page | Close Window

Equation Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16462
Printed Date: 29 March 2026 at 7:00pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Equation Help
Posted By: felix.akinyemi
Subject: Equation Help
Date Posted: 07 September 2005 at 12:56pm
An example of what i want to work out is:

Say i have 5305 points and there's a ranking system 1-10

I need an equation that i can use in ASP to workout where i will rank in the rank system of 1-10 with 5305 points!!

anybody good at maths here??



Replies:
Posted By: dj air
Date Posted: 07 September 2005 at 1:47pm
need alittle more details than that

is the pouints stored in a database?

you could use a order BY within a query and loop 10 times

etc

is this any nmber of points and you want to work out the top 10


Posted By: felix.akinyemi
Date Posted: 08 September 2005 at 6:04am
Yeah its any number but its not to get a top 10, its to get their position in the rank between 1-10



Posted By: ub3rl337ch3ch
Date Posted: 11 September 2005 at 6:59pm
do an order by score (desc), then loop it ten times with a counter each going up once each time, something like this:
 
counter = 0
vrec.open
do until counter = 10
counter = counter + 1
if vrec("score") = score then
response.write "Your ranking is " & score
end if
vrec.movenext
loop
vrec.close
 
 
however, if you wanted to get rankings for multiple scores, and have them accessed regularly, it might be worth adding a rank field to the database, then do this whenever you add new data (say add a button to click after you've finished adding it)
 
sql = "select id from tbl1 order by score desc"
counter = 0
vrec.open sql,adoCon
do until vrec.eof
counter = counter + 1
id = vrec("id")
sql = "update tbl1 SET rank = " & counter & " WHERE id =" & id
adoCon.execute sql
vrec.movenext
loop
vrec.close
 
This will give each of the records a rank based on their score, and then you can just display the rank field instead of having to process the rank each time you want to display it.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net