0

我在此页面http://jian.comoj.com/countdown.php上的计时器没有倒计时。我按照视频教程进行操作,但不知何故出了点问题,我不知道它是什么。

<?php
include "connect.php";
$query= "select * from product where product_id='1'";
$result= mysql_query($query);
$record= mysql_fetch_object($result);
$time= $record->end_time;
date_default_timezone_set('Asia/Singapore');
$unix_time= strtotime($time);

?>

<script type="text/javascript">

    function countdown(){

        <?php 
            $now= time();

            $sec= $unix_time-$now;

            $min= $sec/60;

            $hour= $min/60;

            $sec %= 60;

            $min %= 60;
            ?>

        var hour= <?php echo floor($hour); ?>;
        var min= <?php echo $min; ?>;
        var sec= <?php echo $sec; ?>;
        document.getElementById("hour").innerHTML = hour;
        document.getElementById("min").innerHTML = min;
        document.getElementById("sec").innerHTML = sec;
        setInterval('countdown()',1000);
    }

</script>

<div id="hour"></div>
<div id="min"></div>
<div id="sec"></div>

<script type="text/javascript">countdown();</script>
4

1 回答 1

0
function countdown(){

        var hour= 3;
        var min= 39;
        var sec= 58;
        document.getElementById("hour").innerHTML = hour;
        document.getElementById("min").innerHTML = min;
        document.getElementById("sec").innerHTML = sec;
        setTimeout('countdown()',1000);
    }

查看它们固定的功能,即小时、分钟和秒。

于 2012-05-22T21:02:14.093 回答