Link to home
Start Free TrialLog in
Avatar of level9wizard
level9wizardFlag for Canada

asked on

Delegating SQL updates to rows democratically

THE CHALLENGE
- Let's say I have 5 users (rows) in a table called Players.
- I may add or remove a Player in at any time.
- Each Player has a field 'Cards' to store dealt cards (just an integer of total received so far).
- At any random point/time in the day the dealer [dealer.php] may deal a card to a user.

Using PHP and/or MySQL How can I make sure that is it sequential? Such that user 1 gets a card, and then user 2, and then user 3 until all Players [rows] have got one, and then start back at Player one again.

THE PROBLEM
I/you can't simply fetch the rows from MySQL because it doesn't just happen once (like dealing 52 cards in one shot). Instead, there's really an infinite number of cards (or at least an unknown amount). Also, the dealer may send a card at any time and doesn't know who had one last, and since the rows of Players are dynamic the php function will need to account for this.

END GOAL
The end goal is to then 'weigh' certain players such that they will receive 2 cards in one round where others get only 1. I want to use a 'Weight' field for each player. By default all players have a weight of '1' and having a greater weight such as '3', means they recieve 2 more cards each round.
ASKER CERTIFIED SOLUTION
Avatar of loki23
loki23

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial