I'm just starting to learn php. I have a quiz, were every correct answer gets different points. I looked on the internet, but up till now I coouldn't find the solution. This SO question helped me, but one way another I can't get the total score and that is what I'm looking for. I want to display the total score on the same page. Here is the code were there is something wrong. There is some Dutch in it, but that is not the issue:
<?php
$strSQL="select vraag, vraagnummer, image_1, image_2, image_3, image_4, punten, antwoord ".
"from tbvragen as v ".
"inner join tbpunten as p ".
"on v.id_ptn = p.id_ptn ".
"inner join tbantwoorden as a ".
"on v.id_antw=a.id_antw ";
$rs = mysql_query($strSQL, $db);
while ($r = mysql_fetch_array($rs))
{
?>
<form>
<h3>Vraag <?php echo($r["vraagnummer"]);?> <?php echo($r["vraag"]);?><span>(<?echo($r["punten"]); ?> punten)</span>
</h3>
<ul>
<li><img src="images/<?echo($r["image_1"]); ?>" /><input type="radio" name="keuze" value="A" /><label>A</label></li>
<li><img src="images/<?echo($r["image_2"]); ?>" /><input type="radio" name="keuze" value="B" /><label>B</label></li>
<li><img src="images/<?echo($r["image_3"]); ?>" /><input type="radio" name="keuze" value="C"/><label>C</label></li>
<li><img src="images/<?echo($r["image_4"]); ?>" /><input type="radio" name="keuze" value="D" /><label>D</label></li>
<li><input type="hidden" name="keuze" value="<?php echo($r["antwoord"]);?> " /></li>
</ul>
</form>
<?php
}
?>
<form name="quiz" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post"><input type="submit"
class="button" value="verstuur je antwoorden" name="verstuur" /></form>
<?php
$rs = mysql_query($strSQL, $db);
while ($r = mysql_fetch_array($rs))
{
$beantwoord=$r["vraag".isset($_POST['keuze'])];
$juistAntw=$r["antwoord"];
if ($r["vraagnummer"]==$r["antwoord"]) {
echo $r["punten"].'<br />';
}
}
echo ("je hebt".$r["punten"]." punten");
?>
<?php
mysql_free_result($rs);
mysql_close($db);
?>