Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I am trying to write a script to delete entries from a mysql db after seven days. Getting/comparing/deleting the data is not the problem. The problem is how do I get the date seven days ago?
My table has a timestamp field, so I just need to write a script that determines the current date/time and compare it to this field. I've already determined that I need to get the current date/time in mysql or I will have trouble with different formats. I found the DATE_SUB function in the MySql manual, which looks like it does what I need. Nut my problem is how to get that info into PHP. To make things easier for this post, lets use this simple code:Code: Select all
$sqlsevenago = "SELECT DATE_SUB(NOW(), INTERVAL 7 DAY)";
$myresult = mysql_query($sqlsevenago);
$sevenago = ????? //I need to know what goes here.
echo "$sevenago";If anyone can help me figure out how to make the above example work, I should be fine.
Thanks in advance.
feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]