Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Equation Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Equation Help

 Post Reply Post Reply
Author
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Topic: Equation Help
    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??
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.