Hi
I have a mysql database loaded with info. 1 column is called "dotrav" & it contains a date in the format of yyyy-mm-dd.
I want to delete all the rows in the database that are older than 2 months going back from today's date. The foolowing is the script I've written.
$currentyear = date("Y"
;
$thismonth = date("m"
;
$today = date("d"
;
$two_months_ago = ($thismonth - 2);
$olddate = "$currentyear-$two_months_ago-$today";
$delete = "DELETE from reserve where dotrav <= '$olddate'";
$deleta =@mysql_query($delete, $connection)or die(mysql_error());
1) First of all it will only remove dates from 2 months ago but not 3 moths ago or older
2) I'm sure there's a better way to do this (maybe using the strtotime function and converting it to the Unix Timestamp but I'm not sure how to intergrate this with the Mysql statement)
Please help!!!
I have a mysql database loaded with info. 1 column is called "dotrav" & it contains a date in the format of yyyy-mm-dd.
I want to delete all the rows in the database that are older than 2 months going back from today's date. The foolowing is the script I've written.
$currentyear = date("Y"

$thismonth = date("m"

$today = date("d"

$two_months_ago = ($thismonth - 2);
$olddate = "$currentyear-$two_months_ago-$today";
$delete = "DELETE from reserve where dotrav <= '$olddate'";
$deleta =@mysql_query($delete, $connection)or die(mysql_error());
1) First of all it will only remove dates from 2 months ago but not 3 moths ago or older
2) I'm sure there's a better way to do this (maybe using the strtotime function and converting it to the Unix Timestamp but I'm not sure how to intergrate this with the Mysql statement)
Please help!!!