Zinn Posted June 8, 2022 Share Posted June 8, 2022 Hello Coding Masters, Thank you for reading my post. I need your help if if it's possible that Database table value will automatically update the value when time expires? Sample, If now time is is between ENTRYTime and CLOSE Time, table value will automatically update if time set expires? Enabled value is = 0 on my tableDisabled value is = 0 on my table. But I have someone close to me suggested if its possible to set these automatically? Thank you so much for your feedback. Quote Link to comment https://forums.phpfreaks.com/topic/314903-auto-update-database-table-value-when-time-expires/ Share on other sites More sharing options...
Barand Posted June 8, 2022 Share Posted June 8, 2022 If I understand corrrectly, no update is required - just query the data SELECT CASE WHEN now() BETWEEN entrytime AND closetime THEN 'Enabled' ELSE 'Disabled' END as status FROM .... Quote Link to comment https://forums.phpfreaks.com/topic/314903-auto-update-database-table-value-when-time-expires/#findComment-1597104 Share on other sites More sharing options...
Zinn Posted June 8, 2022 Author Share Posted June 8, 2022 Thank you so much @Barand Sir, Definitly try this one and let you know. The thing is, I get this value (1) of enabled if users will try to submit attendance. And if that user is late, she will no longer be able to submit attendance. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/314903-auto-update-database-table-value-when-time-expires/#findComment-1597111 Share on other sites More sharing options...
Phi11W Posted June 8, 2022 Share Posted June 8, 2022 2 minutes ago, Zinn said: Thank you so much @Barand Sir, Definitly try this one and let you know. The thing is, I get this value (1) of enabled if users will try to submit attendance. And if that user is late, she will no longer be able to submit attendance. Thank you. Barand's point is that you don't need the enabled field at all. Your application should allow submissions when the current date/time is between entrytime and closetime. At any other time, it should not allow submissions. Showing which items are available is a problem for the client web page - Javascript's much better at that sort of thing. (Of course, your server-side Application still needs to check those date/times!) Having databases try to update themselves in near-real time is a pretty difficult undertaking and assumes that your database is always, always available and working and properly. Take it from a 30+ year professional ... 100% Availability is a Myth. Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/314903-auto-update-database-table-value-when-time-expires/#findComment-1597113 Share on other sites More sharing options...
Zinn Posted June 8, 2022 Author Share Posted June 8, 2022 Hello @Phi11W Yes correct! I got Barand's idea and I will follow this best idea than my complex one. You have a good point and thank you for your initiative. Appreciate your help guys. I will update here once everything set on my end. Thank you so much. Regards, Zin Quote Link to comment https://forums.phpfreaks.com/topic/314903-auto-update-database-table-value-when-time-expires/#findComment-1597114 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.