mahalleday Posted October 2, 2009 Share Posted October 2, 2009 I am creating a classifieds application useing php and mysql. I when an ad is created the user can select the duration they want their ad to run. In the database an ad_start and ad_end is created. The ad_end feild is created like this ADDDATE(NOW(), INTERVAL '$ad_durr' day) I then use the following code at the top of the file to display ads to check and see if any ads should be expired and if so set expired = 1 <?php $sql = "SELECT ad_id FROM ".TABLE_PREFIX."mod_ad_baker_ads WHERE ad_end <= CURDATE()"; $query = $database->query($sql) OR die($sql); while($exipred = $query->fetchRow()) { $sql = "UPDATE ".TABLE_PREFIX."mod_ad_baker_ads SET expired = 1 WHERE ad_id = ".$expired['ad_id']; $query = $database->query($sql) OR die($sql); } ?> This is the code I have wrtten when a user wants to renew their ad <?php $sql = 'UPDATE '.TABLE_PREFIX.'mod_ad_baker_ads SET expired = '.$value', ad_end = ADDDATE('.$start.', INTERVAL '.$duration.'DAY), WHERE ad_id = '.$id; $query = $database->query($sql); ?> The ads expire fine but I can't get the renew script to change the ad_end feild when the ads is renewed. Quote Link to comment https://forums.phpfreaks.com/topic/176248-updating-mysql-date-field/ Share on other sites More sharing options...
fenway Posted October 8, 2009 Share Posted October 8, 2009 Echo the actual SQL statements Quote Link to comment https://forums.phpfreaks.com/topic/176248-updating-mysql-date-field/#findComment-933410 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.