Jump to content

delete after row expires


kirkh34

Recommended Posts

i have two tables of user messages that when put in the trash, receive a date 2 weeks ahead of the current time in the trash_expire column, i am trying to make an if statement, if now is greater than the expiration, delete the row....i cannot get this right i have tried for days

$sql = mysql_query("SELECT * FROM message_sent WHERE message_trash = 1 UNION SELECT * FROM message_rec WHERE message_trash = 1")
or die (mysql_error());

while
       ($row = mysql_fetch_array($sql)) {


$trash_expire = $row['trash_expire'];
$trash_expire = strtotime($trash_expire);
$now = strtotime("now");

if ($trash_expire < $now) {

	$sql = mysql_query("DELETE FROM message_rec WHERE trash_expire < '$now'")
		or die (mysql_error());
	$sql = mysql_query("DELETE FROM message_sent WHERE trash_expire < '$now'")
		or die (mysql_error());

   }
   

   
  

} //close while
  

 

Link to comment
https://forums.phpfreaks.com/topic/201595-delete-after-row-expires/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.