tqla Posted December 31, 2008 Share Posted December 31, 2008 Hello. I have a boolean field in my table - either True or False. Is it possible to make a PHP/MySQL script that will automatically change the field from True to False and vice versa? For example: On Feb 1st, 2009 make this field True. On March 1st, 2009 make it False. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/ Share on other sites More sharing options...
dennismonsewicz Posted December 31, 2008 Share Posted December 31, 2008 I would just check the current time and then if it is on this date update the field to this and then when it gets to the other date update the field again Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727130 Share on other sites More sharing options...
tqla Posted December 31, 2008 Author Share Posted December 31, 2008 Hello dennismonsewicz, Do you mean something like this? $date = date(); $true_date = "a manually input date" $false_date = "a manually input date" if ($date = $truedate){ code to change field to True } if ($date = $falsedate){ code to change field to False } If so, how do I match date() with a date that I have input? ("a manually input date") Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727160 Share on other sites More sharing options...
Maq Posted December 31, 2008 Share Posted December 31, 2008 What's the schedule? Every first of the month? If so, just set up a cronjob (or scheduled task for windows) in your crontab that runs every 1st of the month and updates the database. Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727162 Share on other sites More sharing options...
tqla Posted December 31, 2008 Author Share Posted December 31, 2008 Hello Maq, actually, the schedule will vary. It's so that I can have control over when a page will be visible or not. For example, I want the ability to say that the page will be visible from Feb 1st, 2009 to March 1st, 2009. The dates will be different per Page and I will have the ability to change them at will. Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727164 Share on other sites More sharing options...
dennismonsewicz Posted December 31, 2008 Share Posted December 31, 2008 take a look at http://us.php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727169 Share on other sites More sharing options...
tqla Posted December 31, 2008 Author Share Posted December 31, 2008 Thanks dennismonsewics, I'll do it like this. $date = date("m/d/y"); $true_date = "02/01/09"; $false_date = "03/01/09"; Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727171 Share on other sites More sharing options...
dennismonsewicz Posted December 31, 2008 Share Posted December 31, 2008 Sweet i hope everything works out bud! Quote Link to comment https://forums.phpfreaks.com/topic/139026-solved-change-field-on-a-certain-date/#findComment-727176 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.