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";
– Mitchell
Will NOW() > ads_featured_date work?
– Mitchell
Need to do this with PHP? Why not do it right with SQL all?
– Woss
What do you mean???»
– Mitchell
Show an idea of this function that does what I want..
– Mitchell
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.– Woss