Why would the second criterion in this WHERE clause be ignored?
$old = time() - 2592000;
$sql_deleteold = ("DELETE FROM todolist WHERE status='done' AND stamp < $old");
mysql_query($sql_deleteold);
I want to delete data from the database older than 30 days with the status “done”.
Instead it will go deleting all rows with the status “done”.
I think that your question is referring to the “second statement” in the SQL query?
With this assumption, the problem with all rows being deleted with the status “done” is because the WHERE filters are similar to conditional statements like the ones used in “If” statements.
If the first statement, or WHERE filter is true, then execute.
Try doing the following:
You also might want to verify the value of $old and compare it to the values in the ‘stamp’ field of your table, to be sure that there are some rows that have a value in the ‘stamp’ field that are greater than the value of $old.