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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.