Re: How to delete 3 months old records in my database?
| From: | Jim Giner | Date: | Fri, 02 Aug 2013 13:31:57 +0000 |
| Subject: | Re: How to delete 3 months old records in my database? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321764@lists.php.net to get a copy of this message | ||
On 8/2/2013 6:58 AM, Karl-Arne Gjersøyen wrote:
Hello again, folks! I wish to delete records in my database that is older than 3 months. $todays_date = date('Y-m-d'); $old_records_to_delete = ??? if($old_records_to_delete){ include(connect.php); $sql = "DELETE FROM table WHERE date >= '$old_records_to_delete'"; mysql_query($sql, $connect_db) or die(mysql_error()); } Thank you very much for your help to understand also this question :) Karl So close! BUT - you need to reverse your test.where date <= '$old_records_to_delete'