title: Adding a score in a quiz with php and mysql were answers heeft different points
body: <p>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. <a href="https://stackoverflow.com/questions/14462380/how-can-i-see-if-the-users-choice-in-the-quiz-is-correct">This SO question</a> 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:</p>
  
  <pre><code>    &lt;?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))
      {
      ?&gt;
  
      &lt;form&gt;
      &lt;h3&gt;Vraag &lt;?php echo($r["vraagnummer"]);?&gt;  &lt;?php echo($r["vraag"]);?&gt;&lt;span&gt;(&lt;?echo($r["punten"]); ?&gt; punten)&lt;/span&gt;
      &lt;/h3&gt;
      &lt;ul&gt;
      &lt;li&gt;&lt;img src="images/&lt;?echo($r["image_1"]); ?&gt;"  /&gt;&lt;input type="radio" name="keuze" value="A" /&gt;&lt;label&gt;A&lt;/label&gt;&lt;/li&gt;
       &lt;li&gt;&lt;img src="images/&lt;?echo($r["image_2"]); ?&gt;" /&gt;&lt;input type="radio" name="keuze" value="B" /&gt;&lt;label&gt;B&lt;/label&gt;&lt;/li&gt;
      &lt;li&gt;&lt;img src="images/&lt;?echo($r["image_3"]); ?&gt;" /&gt;&lt;input type="radio" name="keuze" value="C"/&gt;&lt;label&gt;C&lt;/label&gt;&lt;/li&gt;
       &lt;li&gt;&lt;img src="images/&lt;?echo($r["image_4"]); ?&gt;" /&gt;&lt;input type="radio" name="keuze" value="D" /&gt;&lt;label&gt;D&lt;/label&gt;&lt;/li&gt;
       &lt;li&gt;&lt;input type="hidden" name="keuze" value="&lt;?php echo($r["antwoord"]);?&gt; " /&gt;&lt;/li&gt;            
      &lt;/ul&gt;
     &lt;/form&gt;
  
     &lt;?php
      }
  
      ?&gt;
     &lt;form name="quiz" action="&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" method="post"&gt;&lt;input type="submit" 
     class="button" value="verstuur je antwoorden" name="verstuur" /&gt;&lt;/form&gt;
  
  
  
  
  
  
       &lt;?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"].'&lt;br /&gt;';
      }
  
      }
      echo ("je hebt".$r["punten"]." punten");
      ?&gt;
  
  
  
        &lt;?php
  
        mysql_free_result($rs);
        mysql_close($db);    
        ?&gt;   
  </code></pre>