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.

Link to comment
Share on other sites

I meant if I had to select all (for an example) Swimmers I have to select all rows that first priority is swimming AND all other rows where swiming is one of next priorities WHERE previeous (eg first, second) did not met .

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.