Jump to content

Selecting data with multiple priorities and limited max entries


rikitons

Recommended Posts

I need to create a PHP script that selects data from MySQL table with multiple priorities?

Every MySQL row is an application for several "sports discipline" with sportsman score as the key for rating.

Sports columns holds the priority for each participient wish to participiate in exact sport. There are limited places for each sports.

That means If his first priority doesn't met (eg. he is 31st in the list, but there are only 30 places available) then the next priority must be as his wish.

An example:

ID  | Name   | Tenis   | Swiming  |  Basketball | Runing     | Score|
-----------------------------------------------------------------------
1   |John    |0        |1         |2            |3           |80    |
-----------------------------------------------------------------------
1   |Bill    |1        |2         |3            |4           |65    |
-----------------------------------------------------------------------
1   |Arnold  |0        |1         |0            |2           |70    |
-----------------------------------------------------------------------

Every disciple has its maximum participients. For an example:

$max_tenis = 5;

$max_swiming = 8;

$max_basketball = 10;

$max_runing = 9;



I qould like to select all applications for each sports and checking if they are met with the limitation set.

So that if I'm selecting all basketballs I must select all other applications with priorities more than the first priority (or second, third...) if the last priority do not met limitation.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.