Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
yeko is on a distinguished road
 
Posts: 6
Join Date: Jun 2008
Default Countdown clock ticks - 09-20-2008, 09:40 PM

I am making a text-based browsergame that is based on time events. I am now creating a script in php / javascript wich is a countdown clock that counts down from 3 minutes to 0.

It is important that this clock is the same for every visitor and doesn't stop counting when the page is refreshed. If the clock reaches 0 then it must start at 3 min againg.


I have written a script but it doens't work. It counts down till 0 but doens't reset to 3 minutes then but is just keeps ticking down under 0.

Can someone help me with this problem ? Maybe it's possible with a cronjob ?

My script
----------------------------------
<?php
include('contactdb.php');
?>

<HTML>
<HEAD>
<BODY>

<form name=myForm>
<input type="text" name="clock" size="6"></form>

<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);

var nu = new Date();
var tick = new Date();

<?php
$sql = "SELECT Minuten FROM `tickgegevens`";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($res) or die(mysql_error());
?>

tick.setMinutes(<?php echo $row['Minuten']; ?>);


var verschil = new Date();
verschil.setTime(parseInt(tick.getTime()-nu.getTime()));
tmin = (Math.round(verschil.getTime()/1000/60)-1);
tsec = (60-nu.getSeconds());

if(tmin <= 9){tmin="0"+tmin}
if(tsec <= 9){tsec="0"+tsec}



if (tsec == 01) {
if (tmin == 00) {
<?php
$tabelMin=date("i")+1;
$tabelSec=date("s");

$sql = "UPDATE `tickgegevens` SET Minuten='$tabelMin', Seconden='$tabelSec'";
$res = mysql_query($sql) or die(mysql_error());
?>
} }

document.myForm.clock.value=""+tmin+":"+tsec+"";

}

runClock();

//--></script>

</BODY>
</HEAD>
</HTML>
--------------------------------------

Last edited by yeko : 09-22-2008 at 06:07 PM.
Reply With Quote
(#2 (permalink))
Old
Junior Member
yeko is on a distinguished road
 
Posts: 6
Join Date: Jun 2008
Default Nobody knows the solution ? - 09-24-2008, 05:49 PM

Somebody knows the answer ?

thanks in advance

Last edited by yeko : 09-24-2008 at 05:51 PM.
Reply With Quote
(#3 (permalink))
Old
Junior Member
yeko is on a distinguished road
 
Posts: 6
Join Date: Jun 2008
Default 10-16-2008, 02:07 PM

nobody knows the answer ?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com