Simply put, I have a field in a MySQL database called expdate (of type DATE) which is the Expiry Date of the record, and ever so often I want to kick off a PHP5 function .disableExpired() that will do the following:
1 – Get all records from Table
2 – Check if their expdate has past based on now()
3 – Set a status field in that case (disabled)
Now, I know how to do (1) and (3) but honestly I’ve got no clue how to do (2) which is comparing the date from my table (Date field in MySQL) and NOW() in PHP5 and how to do something conditional (if) based on that …
So far this is what I have
[Code]
$record = $this->db->Select(“SELECT id, expdate FROM table WHERE status = 1”);
foreach($record as $key=>$val)
{
$id = $val[id];
$expdate = $val[expdate];
// ??? DO THE MAGIC HERE ??? ///
if (past expiry date)
{
$this->setStatus($id, ‘0’);
}
}
As you can see … missing the key element …
Any help would be much appreciated…
Thanks,