Guest Posted December 13, 2012 Share Posted December 13, 2012 I have some php code that supervisors use to assign work to employees. I've added a field named clerks. There are 10 clerk names in the phpmyadmin database..clerk1, clerk2, clerk3, and so on to clerk10. I need for the clerk names to be automatically added to the clerk field in the form when it is opened..for instance, if the form is opened clerk1 is automatically inserted. And the next time it is opened, clerk2 is inserted until it reaches clerk10 & then starts over by inserting clerk1....is this possible?Like I said, I have a table in the database named clerk_names & the clerk's name is listed in this table. The database name is named flow. Any help will be greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/271961-code-help-requested/ Share on other sites More sharing options...
Psycho Posted December 13, 2012 Share Posted December 13, 2012 You say you've added a "field" into the database. That implies you've added that field as part of some existing table - so I'm not understanding what you mean by that. Based upon how you want to use this data I think you need a table with fields for clerk_id, clerk_name, and last_used. The last_used field will be a timestamp value to indicate the last time the clerk was used on the form. So, on each page load of the form you would run two queries: one to get the clerk with the oldest "last_used" date and another to update their "last_used" date to the current timestamp. Quote Link to comment https://forums.phpfreaks.com/topic/271961-code-help-requested/#findComment-1399189 Share on other sites More sharing options...
Guest Posted December 13, 2012 Share Posted December 13, 2012 Ok, I'll do that...thanks...What am I doing wrong here with the settings in PHPMYADMIN? Field = last_used Type = timestamp Length/Value = Default = Current_Timestamp Attributes = Null = Quote Link to comment https://forums.phpfreaks.com/topic/271961-code-help-requested/#findComment-1399191 Share on other sites More sharing options...
Barand Posted December 13, 2012 Share Posted December 13, 2012 I don't see the advantage in using a timestamp instead of datetime. A timestamp can be set to auto-update when the record is updated but in this case it is only the timestamp itself that will be updated (SET last_used = NOW() ) so it may as well just be an ordinary datetime field. Quote Link to comment https://forums.phpfreaks.com/topic/271961-code-help-requested/#findComment-1399197 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.