Forum Moderators: coopster

Message Too Old, No Replies

Ranking system strategies

         

dkin

12:29 am on Jan 7, 2005 (gmt 0)

10+ Year Member



I am writing a small game right now and I want to have a ranking system based on wins losses and ties, now say there are three teams.

Team WINS LOSSES TIES Points

Team A 7 2 1 15
Team B 5 3 3 13
Team C 3 5 4 10

I want I want the db to automatically update the points and order them accordingly. Probably easy but my brain is fried from the rest of the website.

jatar_k

5:30 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



can't you just use update queries?

TeamA beats TeamC

update tablename set wins=8, points=16 where team='Team A';
update tablename set losses=6 where team='Team C'

the logic around how php would construct those queries is longer but fairly straight forward.

1. get present rows for the 2 teams
2. get result of game
3. calculate new points based on result
4. update both rows