我的目标是......
如果日期已过期...脚本会再向用户提供1天,如果未订阅,则会删除用户数据。
我怎么能这样做?......我尝试过INTERVAL 1天,但是......我不知道是否有效......
// Check Expire Dates and Delete Expired 1 day after.
$now = date('Y-m-d');
if ($row['expire_admin'] > $now)
{
echo " <a href='#' id='profileGhost'> ". $row['expire_admin'] . "</a>";
}
else
{
echo " <a href='#' id='profileGhost'>Expired.</a>";
$queryExpire = "DELETE FROM public_vips WHERE expire_admin(expire_admin, INTERVAL 1 day), steamid='$steamID'";
$expiredQ = mysqli_query($db, $queryExpire);
}
答案 0 :(得分:1)
您的SQL应该是
DELETE FROM public_vips
WHERE expire_admin(expire_admin, INTERVAL 1 day)
AND steamid='$steamID'
答案 1 :(得分:0)
// Check Expire Dates and Delete Expired 1 day after.
$now = new DateTime();
$tomorrow = new DateTime();
$tomorrow->add( new DateInterval( 'P1D' ) );
$expiration_date = DateTime::createFromFormat('Y-m-d', $row['expire_admin'] );
if ( $expiration_date->format('u') > $now->format('u') )
{
if( $expiration_date->format('u') < $tomorrow->format('u') )
echo " <a href='#' id='profileGhost'> ". $row['expire_admin'] . "</a>";
}
else
{
echo " <a href='#' id='profileGhost'>Expired.</a>";
// I suppose that steamID is the unique id of the row you are currently check
$queryExpire = "DELETE FROM public_vips WHERE steamid='$steamID'";
$expiredQ = mysqli_query($db, $queryExpire);
}
}