Jump to content

addition and sessions


bearzilla

Recommended Posts

I have table with 11 columns, one of which is an auto-increment id that I use to track a session. The other 10 are quest_one, quest_two, etc... These will have the value of "Correct" or "Incorrect." What would the query be on the last page that adds and outputs, "You answered 6 out of 10 correctly"?
Link to comment
Share on other sites

Why not just create a session variable that counts up as each question is answered correctly?  Or are you trying to run all your "sessions" through a database table for a particular reason?

Something as simple as:

[code=php:0]
if($quest1 == "correct") $_SESSION['correct'] += 1;
[/code]

On each page...followed by

[code=php:0]
echo("You answered ".$_SESSION['correct']." of 10 questions correctly.";
[/code]

on the last page would make the most sense to me...
Link to comment
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.