Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-17-2004, 11:56 AM   #1 (permalink)
gdark59
Registered User
 
Join Date: Sep 2004
Posts: 1
gdark59 is on a distinguished road
php quiz

Hi, im making a quiz that runs on php, I'd like to know if there's any way to embed a timer, and when the time is over, the form submits itself a MySQL db.

Thanks in advance.
gdark59 is offline   Reply With Quote
Old 09-18-2004, 10:19 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
i meant to reply to this last night, but i got side tracked.

ok, there are 2 ways you can do this. since php doesn't run client side, then you would have to use javascript if all the questions were on the same page. there are all sorts of inconsistancies you could run into with javascript including someone having it turned off, so here is what i did.

store the array of questions in a session variable.

on the first question, create a $start_time variabe and store that in the session variable

at this point create an "expired_time" variable for when it is too late for them to answer anymore questions.

display one question at a time. before you display the question, test for
PHP Code:
<?
if(time() >= $expired_time){
  
$header("location: end_quiz.php");
}
?>
or something like that. basically, if their time is up, it just re-directs them to a new page that may calculate their score, or just submit the answers. i don't know if you are grading the quizes in php.
__________________
Mike
sde is online now   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Command-Line Arguments? Antagony PHP 4 09-24-2009 08:46 AM
PHP Comes of Age sde Code Newbie News 0 04-14-2004 12:41 PM
new to php jhoop2002 PHP 12 08-06-2003 03:45 PM
I need to learn PHP Nitro PHP 9 06-28-2003 12:24 PM
PHP as CGI?? bdl PHP 8 05-08-2003 09:29 AM


All times are GMT -8. The time now is 09:16 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting