Originally posted by aron
how can i delete everything older than 2 days before todays date.
$date_today = date("Y-m-d");
$sql = "DELETE FROM open_house WHERE open_date<'$date_today - 2' ";
$sql_result = mysql_query($sql,$connection) or die ("Could not connect to database1");
This might help if it's a datetime field:
<?php
$intCutOff = strtotime("-2 days");
$sql = "DELETE FROM open_house WHERE open_date < '" . date("Y-m-d h:i:s", $intCutOff) . "' ";
$sql_result = mysql_query($sql,$connection) or die ("Could not connect to database1");
?>
If it's a timestamp, it should work with just $intCutOff. I would test it with a select before running it, to make sure you get you're desired results. :p
HTH!