calculate total score in percentage
<pre><code>&lt;?php
$value1 = rand (1,10);
$value2 = rand (1,10);
?&gt;
&lt;form action="mathq.php" method="post"&gt;

&lt;input type="text" name="input1a" value="&lt;?php echo $value1; ?&gt;" class="value" /&gt;

&lt;input type="text" value="x" class="equa" /&gt;

&lt;input type="text" name="input2a" value="&lt;?php echo $value2; ?&gt;" class="value" /&gt;

&lt;input type="text" value="=" class="equa" /&gt;

&lt;input id="answer" type="text" name="answer" value="" class="answer" /&gt;&lt;br /&gt;&lt;br /&gt;




&lt;input type="submit" value="Submit answer" class="submit"&gt;

&lt;INPUT TYPE="RESET" VALUE="Clear all fields of this form"&gt;

&lt;/form&gt;

&lt;?php

if(isset($_POST['input1a']) &amp;&amp; isset($_POST['input2a']) &amp;&amp; isset($_POST['answer'])) {

$result = $_POST['answer'];
$input1a = $_POST['input1a'];
$input2a = $_POST['input2a'];


if (!empty($input1a) &amp;&amp; !empty ($input2a) &amp;&amp; !empty($result)) {
    //echo '&lt;span class="success"&gt;Success!&amp;nbsp;&amp;nbsp;';

}
     if ($result == $input1a * $input2a)
    {
        print($input1a . ' x ' . $input2a . ' = ' . '&lt;span class="correct"&gt;' . $result . '&lt;/span&gt;' . '&lt;br /&gt;Correct!');

    }
    else
    {
        print($input1a . ' x ' . $input2a . ' = ' . '&lt;span class="incorrect"&gt;' . $result . '&lt;/span&gt;' . '&lt;br /&gt;Wrong!&lt;br /&gt; The correct answer was: ' . '&lt;span class="correct"&gt;' . $input1a * $input2a . '&lt;/span&gt;');
    }

}
?&gt;
</code></pre>

<p>I was wondering how i could calculate total score of right answers after the user hits the submit button? How could i create a loop that would go through the rand number of problems and after it goes through once it exits and outputs the person score as percentage of right or wrong answers.  I'm stuck on this part.  </p>

<p>I was also thinking of another way i could tackle this problem.</p>

<p>A user goes through the rand number of math problems once he is done with practices problem he or she hits Done button and it outputs his score.  Can you give me guidance how i can do this? Thanks.</p>
