PHP + MySQL添加时间倒计时并检查其完成情况

I'm basically looking for something that follows:

  • Player completes transaction
  • System updates MySQL with 10 min countdown
  • Player is unable to complete more transactions until countdown finishes
  • Continued..

Imagine it would work something like this:

mysql_query("UPDATE `players` SET `time`= 10:00 WHERE `id`=$player[id] LIMIT 1");

and

if ( 0 <$player['time']) {
    $error='yes';

Also what field type do I give the MySQL field, that's what confuses me most. How it's stored and if it needs to be 'translated' back for the php.

Thought I'd post my answer for future people with the same problem and only complex answers.

All you have to use is time()+900 or $timePlus = time()+900 which inputs the current time + 10 minutes, as an integer into the MySQL field. You can then use time() or $time = time() whilst verifying against the 'time' field to see if 10 minutes is up. Example below:

$player['time'] > time() // where the time stored in 'time' is greater than the actual time causes an error.

Hope I explained that right and credit to @flyingeagle413 for also suggesting this method (although admittedly a bit late) :P