I need help with a ladder script for a local football (soccer) competiton. I have data in a MySQL table in the following format:

Code:
id
Home
Home Score
Away
Away Score
'Home' and 'Away' store team names. Each Team is obviously scattered among these columns several times.

I need to make a ladder script which calculates how many matches each team has won, lost and drawn. I also need to calculate how many points each team has scored & conceded so far in the season.

Finally the scores have to be ranked by wins, draws, points scored, points conceded etc. (Like the normal football ladders are).

The server is running Linux, Apache, PHP 4.3.0, MySQL 3.23 (this can be upgraded if needed).

Thanks