Skip to main content
April 23, 2007
Answered

PHP IF statement for a dynamic quiz

  • April 23, 2007
  • 1 reply
  • 287 views
I'm making a dynamic quiz maker, so a person puts all the questions, options and the answer and it is stored in a database then echoe'd to a different user. I'm having some trouble with making an answer equal to the one stored in the database, I've never done IF statements before so donno if the syntax is quite right. I'm trying to get it to do this:

<?php if ($Q1 == "echo $row_Recordset1['Answer']")
$score=$score+1 ;
?>

So if the answer specified on the page is equal to that stored in my database then increase the score by one.

Any help would be great
This topic has been closed for replies.
Correct answer Günter_Schenk
the comparison of a form field (Q1) with a recordset value should rather be like this:

--------
<?php
if ($_POST['Q1'] == $row_Recordset1['Answer']) {
$score=$score+1;
}
?>
-------

Does that help ?

1 reply

Günter_Schenk
Günter_SchenkCorrect answer
Inspiring
April 23, 2007
the comparison of a form field (Q1) with a recordset value should rather be like this:

--------
<?php
if ($_POST['Q1'] == $row_Recordset1['Answer']) {
$score=$score+1;
}
?>
-------

Does that help ?