I have a list of users in a specific order. Each week I’d like to bump the order of the queue by one, for example
Week 1
User | Order
a | 1
b | 2
c | 3
Week 2
User | Order
b | 1
c | 2
a | 3
and so on…
Is there a simple way to achieve this with just PHP and MySQL?
Set a weekly cron job:
UPDATE TABLE SET Order = Order-1UPDATE TABLE SET Order = MAX(Order)+1 WHERE Order = 0If you have a restriction to “0” value in Order colummn:
UPDATE TABLE SET Order = MAX(Order)+1 WHERE Order = 1UPDATE TABLE SET Order = Order-1