Jump to content

Creating a League Table


timmaggs

Recommended Posts

Hi everyone,

 

I am working on a PHP football league system but I am totally stuck with my attempts to create a league table which is somewhat vital you may think?

 

I am drawing in the information from a database table aptly called 'tables' with the setup like this:

 

id - teamid - wins - losses - draws - for - against - points - seasonid

 

I am getting the information from the database using:

"SELECT * FROM ".TBL_TABLE." WHERE seasonid='$season' ORDER BY points"

Simple enough (although annoyingly that orders the points from 0 upwards), but from this point I am really struggling to take that data and sort it into the correct data for the table:

 

So order the data collected by:

- Points

- If points equal then by goal difference

- If goal difference equal by goals for

- If goals for equal by least goals against

- If equal then alphabetical

 

So that I can then print out this table data, I have experimented with sort() and asort() but I am pretty confused about what is going on there. I would show you the actual code, but its a mess, and it almost definatly way off the mark in what I need to do.

 

Does anyone have any tips on what I need to look into to find a solution to this?

Sorry if this is really basic but I am just learning PHP right now.

 

Thanks, Tim

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.