Jump to content

Working out time


graham23s

Recommended Posts

Thanks mate!

 

does this look ok?

 

<?php
// Auto delete the users cart 24 hours after making selection
$q_times = "SELECT `date` FROM `fcp_orders`";
$r_times = mysql_query($q_times);
$a_times = mysql_fetch_array($r_times);
   $times = $a_times['date'];
   
$time = $times;
$next = date('Y-m-d H:i:s', strtotime("$time + 24 hours"));

// delete query
$q_delete = mysql_query("DELETE FROM `fcp_orders` WHERE `date` => $next");
?>

 

id test it but i need to wait 24 hours lol

 

cheers

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/122278-working-out-time/#findComment-631411
Share on other sites

No problem. I'm not sure you can compare the date fields with =>, but I could be wrong. If you can't, I'm sure there's a command for comparing dates in MySQL. Else calculate the timestamps in the query, and compare those.

 

Also, shouldn't you surround $next with single quotes, inside the query?

Link to comment
https://forums.phpfreaks.com/topic/122278-working-out-time/#findComment-631449
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.