I have a cron job setup to look every 24 hours for a change in value in subscription table like this, here if current date becomes more than end date of subscription, status field value becomes ‘inactive’
$curdate=date('Y-m-d');
$sql=("UPDATE subscription SET status='inactive' WHERE (end_date < '$curdate')");
I would like to send an email to the user whose subscription has just expired using the above cron job, for which i needs to retrieve the user_id also stored in the same subscription table..
Is there a way i can run a SELECT QUERY along with the above UPDATE QUERY and retrieve the user_id of the user whose subscription has just expired?
Thanks,
Do it in two stages:
to retrieve all the expiring ids. Take that list of ids and stuff it into your update query:
Then re-use the ID list to generate your emails.