Jump to content

time problem


Tandem

Recommended Posts

I'm trying to make a timer for part of a game that i am making. If i member does a certain thing it puts them a 'jail'. For this particular instance, i want the timer to start at 40 and countdown, and once the time has passed, they be removed from the jail. Here's what i've got so far.

[code]
<?php
if ($got_inmates[1] == 40){
$jail_time = mysql_query("SELECT * FROM JAIL WHERE TIME > DATE_SUB(NOW(), INTERVAL 40 SECOND) AND USERNAME='$got_inmates[0]'");
$jail_time_check = mysql_num_rows($jail_time);
$get_sentence_time = mysql_query("SELECT ADDTIME(TIME, '00:00:40') FROM JAIL WHERE USERNAME='$got_inmates[0]'");
if ($jail_time_check < 1) {
$remove_from_jail = mysql_query("DELETE FROM JAIL WHERE USERNAME='$got_inmates[0]'");
}
if ($jail_time_check > 0) {
$got_sentence_time = mysql_result($get_sentence_time, 0);
$timer1 = date('Y-m-d H:i:s');
$timer2 = strtotime($timer1);
$timer3 = strtotime($got_sentence_timer);
$timer4 = $timer3 - $timer2;
$timer5 = date("s", $timer4);
}
if (empty($timer5)){
$timer5 = "0";
}
}
?>[/code]

The problem is that the timer starts at random places, when i want it to start at 40. Can anyone help me out and tell me how to fix it?

Thanks in advance for any help. If you need more info just ask.
Link to comment
https://forums.phpfreaks.com/topic/15974-time-problem/
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.