Ik heb een datum in een database staan in unix timestamp formaat deze wil ik echter verwijderen als hij ouder word dan 14 dagen.
daarvoor heb ik deze code geschreven:
private function Gold($gold_date)
{
// gold date = 14
$gold_date = $gold_date * 60 * 24;
$query = mysql_query("Select * From member where account='GOLD'") or die(mysql_error()); // pak alle gold users
while($array = mysql_fetch_array($query))
{
mysql_query("Delete from p_message WHERE date + INTERVAL $gold_date DAY < UNIX_TIMESTAMP() && member_id = '".$array["member_id"]."'") or die(mysql_error()); // date query van gold account
}
}
privatefunction Gold($gold_date)
{
// gold date = 14
$gold_date=$gold_date*60*24;
$query=mysql_query("Select * From member where account='GOLD'") or die(mysql_error());// pak alle gold users
mysql_query("Delete from p_message WHERE date + INTERVAL $gold_date DAY < UNIX_TIMESTAMP() && member_id = '".$array["member_id"]."'") or die(mysql_error());// date query van gold account
Dat klopt al niet he...
En waarom een unix timestamp? Dat veld op date hbben staan is toch veel simpeler?
Overigs denk ik dat je die $gold_date sowieso van unix_timestamp halen.
private function Plus($plus_date)
{
$plus_date = $plus_date * 60 * 24;
$plus_date = time() - $plus_date;
$query = mysql_query("Select * From member where account='PLUS'") or die(mysql_error()); // pak alle gold users
while($array = mysql_fetch_array($query))
{
mysql_query("Delete from p_message WHERE date $plus_date < UNIX_TIMESTAMP() && member_id = '".$array["member_id"]."'") or die(mysql_error()); // date query van gold account
}
}
mysql_query("Delete from p_message WHERE date $plus_date < UNIX_TIMESTAMP() && member_id = '".$array["member_id"]."'") or die(mysql_error());// date query van gold account