Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- creating a php formula.


Marked - 2:11 pm on Feb 5, 2010 (gmt 0)


Hi all,

I am writing a stats component which contains rankings from 1 to 100.

Each stat module has a ranking. What I am trying to do is give many points for higher rankings(like 1 and 2) and few points for low rankings(such as 100).

At the moment my script has something silly like this:
if($rank == 1){
$points = +=10
}elseif($rank ==2){
$points = +=9
}

And so on. So what I'm looking for is some kind of math formula which when you insert a number such as 1 or 2, the result is high. And if you insert a number such as 100, 99 etc. the result comes out a low number. And if there are some really smart people out there, the results get exponentially lower(for example, ranking 1 gives 10 points, ranking 100 gives 0.0001 points). But I am very unsure how to write such a formula... Can someone offer me some advice on this?

Thanks in advance,
Mark.


Thread source:: http://www.webmasterworld.com/php/4074922.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com