468,121 Members | 1,376 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

how to insert automatically data into mysql table by php after fixed time duration

Actually i am creating a punching tool in which we will punch so that if someone will not that after 6 hour automatically a query would be submitting like a notification so please tell me how can i insert data into mysql table in php automatically.
Apr 17 '19 #1
8 998
5,390 Expert Mod 4TB
not sure what a 'punching tool' is - but i would say that this requirement is to be implemented in another way. you just need a timestamp that is always updated on a request so the application can always compare that timestamp and see if the entry is 'too old' or not.

to have the possibility to update something in an interval by php it would require to run a php process indefinitly - which basically could be done by running a php process at the commandline - preferably as a service on that machine - which isnt a preferable way to do things since the above solution would avoid that already. It would have to check all entries all the time and see which one to update - so it would create unnecessary load on the machine ressources as well as on the database.
Apr 17 '19 #2
okey but how to insert data automatically in mysql database.
Apr 17 '19 #3
5,390 Expert Mod 4TB
why would you need that? there shouldn't be a reason for that - since it simply can be done with correct updates and comparisons of a timestamp.

you would need to explain more what exactly you want to achieve - there are really rare needs of having something like a service that does inserts or updates in a DB periodically - most can/should be solved without such for already mentioned reasons.
Apr 17 '19 #4
i need for a reason that is if employee not submit his entry at office time than after 6 hour automatically system submit a query for him.
Apr 17 '19 #5
5,390 Expert Mod 4TB
let me try to understand that since its still unclearly explained:

an employee should do some entry and when he did not do that entry - basically a record is missing.

now you want to insert some default record for that automatically?
Apr 17 '19 #6
Yes, I want a message should be automatically insert into database like for your understanding like notification.
Apr 18 '19 #7
5,390 Expert Mod 4TB
ok - but whatfor? basically at some point the records will be read from the database - so while doing that a program could react to any missing or 'too old' entries by simply comparing a timestamp or existence of a record. this way the DB wouldnt be polluted with default entries that wouldnt be needed - since a program can generate such notifications on the fly.

if you still insist to insert something into the DB you might simply write a php program that checks which records to be added and start it from a cronjob after the office hours for example. that way there could be a 'job' that inserts those records once per day.
Apr 18 '19 #8
ok Thank you gits i also thinking to do with cronjob but that is possible only on live server not local server. thank you.
Apr 18 '19 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Dave | last post: by
10 posts views Thread by John Smith | last post: by
10 posts views Thread by Trevor | last post: by
5 posts views Thread by Stephen Preston | last post: by
10 posts views Thread by eholz1 | last post: by
18 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.