Well, im coding an advertising scheme type web page at the moment. What I need to do is figure out a way to show people how ranked they are in order of the amount of clicks they have got. For example:
Bob has been clicked 5 times
Jim has been clicked 2 times
Lisa has been clicked 2 times
John has been clicked 10 times
The amount of clicks is stored in an integer field name m_clicks.
Now, when Bob logs in, he has the second most clicks so itll say "You are ranked 2 out of 4."
When Jim logs in, he is tied with Lisa so we'll fix that by doing it alphabetically. It will say "You are ranked 3 out of 4."
When Lisa logs in, she will see "You are ranked 4 out of 4."
And when John logs in he will see "You are ranked 1 out of 4."
At the moment I got it working via checking every row and ordering them in an array. But if my site gets bigger, I dont want to do that with 3000 rows, for example. That wouldnt be nice to do every time someone logs in. Im SURE there is an easier way I just cant place my finger on it! Does anyone have any ideas?
Thanks
SoD
PS: I did a search for this but I got some rubbish about cars or something, it didnt help anyway.
|