I try to delete a row in my DDB in 1 week.
I wrote:
<?php
//in my page
//On click
$today=date("Ymd");
$query = 'INSERT INTO mytable VALUES (id,val,date),("", "'.$val.'", "'.$today'")';
dbb_exe($query);
?>
<?php
//in my header
//Check my table
$today=date("Ymd");
$query = 'SELECT date FROM mytable WHERE id=.'(int)$_GET['id'];
$r_date = dbb_exe($query);
//Here it's where i want delete my row if the row exists since 1 week
if($r_date==($today - "1week")){
//DELETE row
$query = 'DELETE FROM mytable WHERE id=.'(int)$_GET['id];
dbb_exe($query);
}
?>
As you see i don t know how to calcul the var “1week”,
right now i m reading strtotime to try something like $date= strtotime($today);
but i m lost , anyyway i have all the day(+night) to success
Red bull and stackoverflow are my friends.
Thanks to the community
Have a nice day
Mel
Instead of doing all work with php, I believe you can try something like:
This should delete all records from
mytablewithdateequals to the 1 week ago.Replace
=to<if you want to delete all records older than 1 week.