Can never find the answer to my problems - always find something close but not the solution!!!
Anyway, a relative newbie to all this and would like some help as I just can't find the solution with for() continue() next() etc etc - all confusing.
My problem is - I am creating an online roster for a volunteer organistion.
Every day there is a Manager on call, but if they are unavailable, the roster will just go to the next available Name.
If the particular Name is the last row of the table, it needs to Loop back to the top and go through the names in sequential order.
EG
--------------------------
id | Name
----------------------------
1 | Joe
2 | Bill
3 | Bob
4 | Richard
5 | Tom
----------------------------
Scenario
Bill is rostered on, but has indicated via an Admin Form he is unavailable today. Therefore the Roster will indicate Bob as the Duty Manager. If Bob has also indicated not available, then would show Richard as Duty Manager.
If Tom was down as Duty Manager, but was unavailable, would show Joe etc etc
Basically Loops until next available Name (in sequence).
I realise that this could end up an infinite Loop if NO ONE available so would have to break after one / two complete Loops?
My current code I'm experimenting with is (found on the PHP Site) which displays relevant data according to the query string.
PHP Code:
$query = "SELECT * FROM users LEFT JOIN days ON users.id = days.id WHERE users.Avail = 'Y' AND users.Manager = 'y' AND users.Active = 'Y' AND days.tues = 'Y' AND users.Tues = 'Y'";
Seems to be OK, but as soon as the record is updated, the sequential order throws a hissy fit - all good if the record is updated sequentially.
On second thoughts I guess you need to update the `lastused` column ONLY when a person comes up in the search result as a manager on call for that day, since anyway the unavailable users are eliminated using the sql query already.
Also instead of defining the `lastused` column as timestamp type, define it as a normal int type and then store a manually generated php timestamp in it.
Also instead of defining the `lastused` column as timestamp type, define it as a normal int type and then store a manually generated php timestamp in it.
What I have done based on your comments was to define the 'lastused' as a DATETIME, manually set the times say a minute apart (only on Managers, the rest can stay at 00:000 00 whatever), then used a SET lastused= now() ....
The DATETIME then is updated on Search result.
WIll give this a good workover in the next few days and see if it gives me any grief or not. NOT I hope!!!
Bookmarks