You'll want to POST/GET the answers as an array. To do that, you need to name your input fields in this way:
HTML Code:
<input name="ans[]" type="number">
<input name="ans[]" type="number">
<input name="ans[]" type="number">
<input name="ans[]" type="number">
<input name="ans[]" type="number">
The "[]" defines an array in HTML.
Then on the PHP side, to get the number of 'ans' checked off, do this:
PHP Code:
if(isset($_POST['ans'])){
$count = count($_POST['ans']);
}
To count all the answers:
PHP Code:
if(isset($_POST['ans'])){
$count = count($_POST['ans']);
$total = 0;
foreach($_POST['ans'] as $val){
$total += $val;
}
}
Bookmarks