When a player joins a room, it updates the lobby timestamp.
The problem is, I’m trying to use javascript to time the timestamp grab… and nothing’s happening… Here’s the basic code: this is just for the test. I'm pretty new to PHP, but I think this must be a javascript error?
Code: Select all
<HTML>
<HEAD>
<TITLE>timer test</TITLE>
<SCRIPT LANGUAGE="Javascript">
<!--
var x = 3
var y = 1
function startClock() {
x = x-y
document.frm.clock.value = x
if(x==0){
<?PHP
// get lobby timestamp
include("scripts/dbcon.php");
include("scripts/db.php");
$query = "SELECT * FROM rooms_ts";
$result = mysql_query($query);
$tsNum = mysql_num_rows($result);
if (!$tsNum) {
echo "ERROR>> TIMESTAMP INVALID";
} else {
$newTS = mysql_fetch_row($result);
}
}
?>
var stamp = <?= $newTS; ?>
document.frm.ts.value = stamp
x=3;
}
setTimeout("startClock()", 1000)
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" onLoad="startClock()">
countdown in first box, timestamp in second
<FORM NAME="frm">
<INPUT TYPE="TEXT" NAME="clock" SIZE=4 >
<INPUT TYPE="TEXT" NAME="ts" SIZE=5 >
</FORM>
</BODY>
</HTML>