Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/176248-updating-mysql-date-field/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.