Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping Score? passing values through 5 pages, score at end

Status
Not open for further replies.

dallasweb

Programmer
Jan 4, 2001
45
US
I'm creating a online quiz. Each question is random from a database of 15 questions. The quiz has a total of 5 questions.Each question has it's own page. quiz1.cfm, quiz2.cfm,etc..
I run a cfquery on the answer to determine is correct, but can't seem to keep a tally on number of right and wrong answers.
here's the code for adding the score(not working):
Query:
<CFQUERY datasource=&quot;quiz&quot; NAME=&quot;getAnswer&quot;>
SELECT *
FROM quiz
WHERE ID = #form.ID# AND '#form.answer#' = '#form.correct#'
</cfquery>
<CFIF getAnswer.Recordcount IS 0>
<input type=&quot;Hidden&quot; name=&quot;home&quot; value=&quot;#IncrementValue(form.home)#&quot;>
<input type=&quot;Hidden&quot; name=&quot;away&quot; value=&quot;#form.away#&quot;>
<CFELSE>
<input type=&quot;Hidden&quot; name=&quot;away&quot; value=&quot;#IncrementValue(form.away)#&quot;>
<input type=&quot;Hidden&quot; name=&quot;home&quot; value=&quot;#form.home#&quot;>
</CFIF>
Anyone do something like this or can fix?Thanks in advance.
 
The getanswer.recordcount will return a number of records that match the query. If the query only picks up the total of correct answers, then it should return the number of correct answers. From there you can do some subtraction in your code out of the total (you can make this dynamic if you want by getting another variable to return total records or question/answers) and you will have your number of incorrect answers as well. [sig]<p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database web programmer and developer, fueled by peach snapple and mochas.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top