Click to See Complete Forum and Search --> : Help With Count Down


airforcefc
02-16-2007, 01:14 AM
Hello,

Just wondering if anyone knows why when this countdowns to 0 seconds, it takes a second, then enters a loop hole where it continues to refresh over and over without actually refreshing the page? Any Ideas please....


<?php

$expiredate = "2007-02-16";
$expiretime = "18:10";

$exptime = explode(":",$expiretime);
$expdate = explode("-",$expiredate);
$expiretimestamp = mktime($exptime[0],$exptime[1],0,$expdate[1],$expdate[2],$expdate
[0],-1);
$seconds_left = $expiretimestamp - time();

$countdown = ($seconds_left >= 0) ? true : false;
?>
<? include("display_top.php"); ?>

<?php
if ($countdown)
{
?>
<script language="JavaScript">
<!--
function showtime() {
setTimeout("showtime();",1000);
sourcedate.setTime(sourcedate.getTime()-1000);
var hh = (sourcedate.getDate()-1)*24 - 9 + sourcedate.getHours()-1;
if ( hh < 0 ) {
document.all["clock"].innerText = '';
this.location.href = this.location.href;
}
var mm = sourcedate.getMinutes();
var ss = sourcedate.getSeconds();
if (hh >= 0) {
document.all["clock"].innerText = ((hh < 10) ? "0" : "") + hh + ((mm <
10) ? ":0" : ":") +
mm + ((ss < 10) ? ":0" : ":") + ss;
}
}

sourcedate = new Date(<?= date("Y,m,d,H,i,s",$seconds_left);?>);
//-->
</script>
<?php
} // end if ($countdown)
?>
<? include("display_head.php"); ?>
<?php
if ($countdown) // if the expire date/time hasn't been reached
{
?>
The expiredate/time is: <?= $expiredate . ' ' . $expiretime; ?><br>
Time to go: <span name="clock" id="clock" class="top_tbl">Countdown here</span>
<script language="JavaScript">
<!--
showtime();
//-->
</script>
<? include("display_open.php"); ?>
<?php
}
else // Show some other content
{
?>
Round Has Closed: <?= $expiredate . ' ' . $expiretime; ?>
<? include("display_closed.php"); ?>
<?php
}
?>

</div></td>
</tr>
</table>
</div></td>
<td>&nbsp;</td>
</tr>
</table>
</div>
</div>
</body>
</html>