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
https://forums.phpfreaks.com/topic/31620-addition-and-sessions/
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
https://forums.phpfreaks.com/topic/31620-addition-and-sessions/#findComment-146550
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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