I have a javascript flipclock first of all when ever i refresh the page it start from the beginning as I want it to be resumed from where it was stopped before page refresh and I want my timer to be stoped every day at 4:00 AM or 4:00 PM but when I tried to enter some php the clock is not properly showing i don't know is there any php fiddle available so I can show what is the bud like jquery fiddle
我首先有一个javascript flipclock当我刷新它从头开始的页面,因为我希望它从页面刷新之前停止的地方恢复,我希望我的计时器每天凌晨4点停止或者下午4:00但是当我试图进入一些php时,时钟没有正确显示我不知道是否有任何PHP小提琴可用所以我可以显示什么是像jquery小提琴的芽
Here is what i tried to do so
这是我试图这样做的
$query = mysqli_query($connection, "SELECT * FROM timer WHERE id = '1'");
$timer = mysqli_fetch_array($query);
$time_st = $timer[2];
$time_end = $timer[3];
$date = $timer[1];
$time_rem = $date . " " . $time_st;
$rem = strtotime("$time_rem") - time();
$today = getdate();
$time_end = $today['hours'] . ':' . $today['minutes'] . ':' . $today['seconds'];
?>
My Clock
<div class="clock_area">
<div class="clock"></div>
<p>COUNTDOWN TILL 4:20</p>
</div>
<script type="text/javascript">
$(document).ready(function() {
var clock;
clock = $('.clock').FlipClock({
clockFace: 'HourlyCounter',
autoStart: false,
callbacks: {
stop: function() {
$('.message').html('Offer Closed')
}
}
});
<?php
if($time_end == $time_st || $time_end == '04:20:00') {
?>
clock.setTime(0);
<?php } else { ?>
clock.setTime(<?php echo $rem; ?>);
<?php } ?>
clock.setCountdown(true);
clock.start();
});
</script>
Please help me out with this like my scenario is really simple but little bit logical though
请帮我解决这个问题,就像我的场景非常简单但有点合乎逻辑
1 个解决方案
#1
0
You cannot do this
你不能做这个
<?php
if($time_end == $time_st || $time_end == '04:20:00') {
?>
clock.setTime(0);
<?php } else { ?>
clock.setTime(<?php echo $rem; ?>);
<?php } ?>
You should do this
你应该做这个
<scritp>
...YOUR JS CODE...
<?php
if($time_end == $time_st || $time_end == '04:20:00') {
echo "clock.setTime(0);";
}
else{
echo "clock.setTime(".$rem.");";
}
?>
clock.setCountdown(true);
clock.start();
});
</script>
#1
0
You cannot do this
你不能做这个
<?php
if($time_end == $time_st || $time_end == '04:20:00') {
?>
clock.setTime(0);
<?php } else { ?>
clock.setTime(<?php echo $rem; ?>);
<?php } ?>
You should do this
你应该做这个
<scritp>
...YOUR JS CODE...
<?php
if($time_end == $time_st || $time_end == '04:20:00') {
echo "clock.setTime(0);";
}
else{
echo "clock.setTime(".$rem.");";
}
?>
clock.setCountdown(true);
clock.start();
});
</script>