Current location: Hot Scripts Forums » Programming Languages » PHP » php timer that executes an action after a set interval


php timer that executes an action after a set interval

Reply
  #1 (permalink)  
Old 02-03-06, 06:45 AM
zmbz zmbz is offline
New Member
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question php timer that executes an action after a set interval

Hello.
I'm a novice at using php (as you may have heard so many times) and I need guidance for making a timer that executes an action after a set interval. I need at least a hint of a function I could use (even in java under php, or a link).
What I want to do: to make a test that involves a set of questions from a data base-using MySQl (it's all working), but I want to display each question at a set interval of time. For example: I display in a frame the first question, I display the set of answares to choose from (using radio buttons) than I want to alow 1 minute to the user to answer it and then to apear the second question beneeth (under) the first with it's own set of answers, and so on. All I need is to wait 1 minute (or an interval af time, in general) before doing the next action - > showing a question or ending the test and going to another page...
I have tried this way:
//I konow the interval of time in minutes: $duration
$time0=date("i");
$time1=$time0+$duration;
if ($time1>60)
{
$time1=$time1-60;
while (date("i")<=59);
while (date("i")<=$time1);
}
else
{
while (date("i")<=$time1);
};
//action ...open another page...

but all disapears from the frame



I have tried even with sleep(seconds), but it has the same effect.


Thank you.

Last edited by zmbz; 02-03-06 at 07:23 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-04-06, 03:55 PM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by zmbz
Hello.
I'm a novice at using php (as you may have heard so many times) and I need guidance for making a timer that executes an action after a set interval. I need at least a hint of a function I could use (even in java under php, or a link).
What I want to do: to make a test that involves a set of questions from a data base-using MySQl (it's all working), but I want to display each question at a set interval of time. For example: I display in a frame the first question, I display the set of answares to choose from (using radio buttons) than I want to alow 1 minute to the user to answer it and then to apear the second question beneeth (under) the first with it's own set of answers, and so on. All I need is to wait 1 minute (or an interval af time, in general) before doing the next action - > showing a question or ending the test and going to another page...
I have tried this way:
//I konow the interval of time in minutes: $duration
$time0=date("i");
$time1=$time0+$duration;
if ($time1>60)
{
$time1=$time1-60;
while (date("i")<=59);
while (date("i")<=$time1);
}
else
{
while (date("i")<=$time1);
};
//action ...open another page...

but all disapears from the frame



I have tried even with sleep(seconds), but it has the same effect.


Thank you.
I think you would need to use Javascript because PHP is executed server side, you might be able to make a script that takes a minute to execute but there would be no point, because all they would see is a blank page for a minute (or half a page etc).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-04-06, 06:13 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Here is an idea, using a Javasript found on dynamicdrive -
http://www.dynamicdrive.com/dynamici.../seqreveal.htm

Using this javascript as a basis, you could build pages using PHP with your questions -
<div class="revealcontent">Put question1, answers, and links here via PHP.</div>
<div class="revealcontent">Put question2, answers, and links here via PHP.</div>

These will be revealed in turn.

The biggest gotya with this is if they refresh the page, it would start over with the 1st question, but this should be fairly easy to solve.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-10-06, 07:15 AM
zmbz zmbz is offline
New Member
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you, mab for your sugestion. I'll try that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php for countdown timer Makien PHP 2 10-10-05 08:02 PM
ASP upload prob minority ASP 1 06-27-05 09:35 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
Setting a cooke (time it expires) mcrob PHP 4 04-27-05 01:13 PM


All times are GMT -5. The time now is 01:25 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.