Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/52328-php-countdown/
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258200
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258223
Share on other sites

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...  :D

Link to comment
https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258236
Share on other sites

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  ;D

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  ::)

Link to comment
https://forums.phpfreaks.com/topic/52328-php-countdown/#findComment-258238
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.