Add code below straight after the last MySQL insert data statement.
This passes the id number of that row to $inserted_row_id
Then it deletes all you want, but that id number.
1 2 3 4 5 |
$inserted_row_id = mysql_insert_id(); $todayDate = date('Y-m-d'); mysql_query("DELETE FROM table1 WHERE id <> {$inserted_row_id} AND date = '{$todayDate}' AND campaignid = '{$databaseRow['campaignid']}'") or die(mysql_error()); |