PHP - Check all user reminders' dates

Asked

Viewed 17 times

0

Good,

I created a script that aims to determine whether the Column Dates ads_featured_dates are expired or not....

The problem is, the script updates the ones that are past the date, but also the ones that have not yet passed...

How do I resolve?

function check_promotions_date($con) {

  $search_expire_dates = "SELECT ads_featured_date, ads_featured, ads_id 
  FROM public_ads WHERE ads_featured = 1";
  $expire_query = $con->query($search_expire_dates);  

  while($expire_details = $expire_query->fetch_assoc()) {

  $todays_date = date("Y-m-d"); 
  $reset_days = "0000-00-00 00:00:00";       

  if($todays_date > $expire_details['ads_featured_date']) {

      $update_dates = "UPDATE public_ads SET ads_featured_date = '$reset_days', ads_featured = 0";
      $query_updated = $con->query($update_dates);
  } 

 }   

}

  • I changed the update like this... UPDATE public_ads SET ads_featured_date = '$reset_days', ads_featured = 0 WHERE NOW() > ads_featured_date";

  • Will NOW() > ads_featured_date work?

  • Need to do this with PHP? Why not do it right with SQL all?

  • What do you mean???»

  • Show an idea of this function that does what I want..

  • Only if you can describe better what you want to do and present the structures of the tables. In fact, where is the where of your update? Without it, depending on the database configuration, you will always update the entire table.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.