lyax Posted May 21, 2007 Share Posted May 21, 2007 need a simlpe help.. how is it possible? when the user clicks a link, php adds , for example 30 seconds, to the current time and saves it into mysql table as the target time and starts counting down.. 30, 29, 28,... unless it ends, user cant do anything. how is this possible, is it easy or complicated?? i've found some codes in javascript but couldnt use as they are soo long and dont use mysql formatted dates.. any help? Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/ Share on other sites More sharing options...
lyax Posted May 21, 2007 Author Share Posted May 21, 2007 <?php $time1 = "00:00:00"; $time2 = "00:00:30"; echo (strtotime($time2) - strtotime($time1)); // displays the time difference in seconds. echo "<br>"; echo date("H:i:s",(strtotime($time2) - strtotime($time1))); ?> the difference is 30 second here, it prints this but i want to know how to make a countingdown?? unless it ends user cannot do anything.. need some help. Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258200 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 what do you mean by "can't do anything", you could have a frame auto refeash evey second and have the counter call from the database (or session) the new time remaining.. when that hits zero redirect to another page Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258219 Share on other sites More sharing options...
lyax Posted May 21, 2007 Author Share Posted May 21, 2007 i mean user has to wait until the counting ends to see the page or click to a link etc. by the time it is 0, he can see the page.. if else can do this job. if user refreshes the page, it wont start again, will continue.. i know i am asking for more so sorry but this is the problem i am trying to solve for several days... Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258223 Share on other sites More sharing options...
lyax Posted May 21, 2007 Author Share Posted May 21, 2007 can u write an example to your solution? Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258225 Share on other sites More sharing options...
AndyB Posted May 21, 2007 Share Posted May 21, 2007 Can you explain, preferably with specifics, just why you want to force someone to wait 30 seconds before they can click anything? I assume it's not intended to make people leave your site Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258227 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 Oh Great Andy is in this thread.. Sighs.. i would like to point out this is not a my best work but its basic <?php session_start(); $wait = 30; //unset($_SESSION['time']); if( !isset($_SESSION['time']) ) { $_SESSION['time']=time(); echo "Started"; }else{ if(time() >= $_SESSION['time']+$wait) { echo "Done"; //include("hiddenpage.html"); }else{ echo $wait -(time() - $_SESSION['time']); echo "<meta http-equiv='refresh' content='0.5'>"; } } ?> waits for andy to create a great example in 0.2 seconds leaving mine in a bundle of smoke lol i know its not great ok... Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258236 Share on other sites More sharing options...
lyax Posted May 21, 2007 Author Share Posted May 21, 2007 yes, thats true, i know i am trying to create something just like a simple browser game, just to improve my php. The user gives a command to change the region which his/her character is living in and from REGION A to REGION B it takes 30 seconds to go, for example.. İn this case he has to wait for the end of his trip in order to do anything with his/her character, simply so, when he clicks, counting has to start end if the user refreshes the page has not to start over and he has to wait for the and, maybe i can print some jokes to the page Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258238 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 well mine uses the refeash.. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258240 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.