roger01 Posted August 23, 2016 Share Posted August 23, 2016 Hello I currently have this code: $timeBetweenClaims = 1800; $timeQuery = mysqli_query($conn, "SELECT * FROM users WHERE addy = '$userAddy'"); $timeResult = mysqli_fetch_assoc($timeQuery); $timeDif = $time - $timeResult['time']; $timeLeft = gmdate("i:s", $timeBetweenClaims - $timeDif); if($timeDif < $timeBetweenClaims){ $message = "Wait 30 minutes before posting. Timeleft: $timeLeft"; } how to make $timeLeft auto countdown til 0 so users don't have to refresh the page every few minutes to see the progress on timeleft? thank you! Quote Link to comment https://forums.phpfreaks.com/topic/301971-simple-php-countdown-timer-starting-from-sql-time/ Share on other sites More sharing options...
PravinS Posted August 23, 2016 Share Posted August 23, 2016 Try AJAX Quote Link to comment https://forums.phpfreaks.com/topic/301971-simple-php-countdown-timer-starting-from-sql-time/#findComment-1536482 Share on other sites More sharing options...
Jacques1 Posted August 23, 2016 Share Posted August 23, 2016 I don't know how Ajax is going to help with this, but JavaScript can create timers. After the page has been loaded, you start with $timeLeft, count down the seconds and display the remaining time somewhere on the page. There are thousands of examples and working implementations, just google for it. Quote Link to comment https://forums.phpfreaks.com/topic/301971-simple-php-countdown-timer-starting-from-sql-time/#findComment-1536483 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.