Hi
I have a bunch of ID's. I can assign them once a day.
I need to query my database, see if they're any ID's available to hand out (if I didn't hand out all of them in a 24 hour period), and if there's any available, write a new row to the database saying that the ID has been handed out. I also need to know which user held which ID at a certain time.
The only way I can figure this is by creating two tables - one active_ids
(contains who owns a particular ID right now) and one id_records
(contains who owned IDs currently and in the past).
Then I would say something like:
UPDATE active_ids SET user_id=xyz WHERE UNIX_TIMESTAMP(current_timestamp) - UNIX_TIMESTAMP(date) > 84600 LIMIT 1;
and then pusing another record to id_records
with the data.
Is there a way I can do this with one table? I'm using PHP and MySQL.
Thanks!