Good morning, I have a form to do tests in which it accumulates the answers in an array_keys with the correct, incorrect and blank. What I would like to know is if in the form header I can see the correct, incorrect and blank before sending the post.
The variables I accumulate in php like this:
<div id='question<?php echo $i;?>' class='cont'>
<div class="progress">
<span class="orange" style="width: <?php echo $progreso; ?>%;"><span><?php echo round($progreso,0)."%"; ?></span></span>
</div>
<!--<progress value="<?php echo $i; ?>" max="<?php echo $numero; ?>"></progress> -->
<strong><p class='questions' id="qname<?php echo $i;?>"> <?php echo $i?>. <?php echo $result['question_name'];?></p></strong>
<input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer1'];?>
<br/>
<input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer2'];?>
<br/>
<input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer3'];?>
<br/>
<input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer4'];?>
<br/>
<input type="radio" checked='checked' style='display:none' value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/>
<br/>
<div id="botones" class="mm-survey-controller">
<div class="mm-next-btn">
<button id='<?php echo $i;?>' class='next' type='button'>Siguiente</button>
</div>
</div>
</div>
<?php }elseif($i<1 || $i<$rows){?>
<div id='question<?php echo $i;?>' class='cont'>
<div class="progress">
<span class="orange" style="width: <?php echo $progreso; ?>%;"><span><?php echo round($progreso,0)."%"; ?></span></span>
</div>
<strong><p class='questions' id="qname<?php echo $i;?>"><?php echo $i?>. <?php echo $result['question_name'];?></p></strong>
<input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer1'];?>
<br/>
<input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer2'];?>
<br/>
<input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer3'];?>
<br/>
<input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer4'];?>
<br/>
<input type="radio" checked='checked' style='display:none' value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/>
<br/>
<div id="botones" class="mm-survey-controller">
<div class="mm-prev-btn">
<button id='<?php echo $i;?>' class='previous' type='button'>Anterior</button>
</div>
<div class="mm-next-btn">
<button id='<?php echo $i;?>' class='next' type='button'>Siguiente</button>
</div>
</div>
</div>
<?php }elseif($i==$rows){?>
<div id='question<?php echo $i;?>' class='cont'>
<div class="progress">
<span class="orange" style="width: <?php echo $progreso; ?>%;"><span><?php echo round($progreso,0)."%"; ?></span></span>
</div>
<strong><p class='questions' id="qname<?php echo $i;?>"><?php echo $i?>. <?php echo $result['question_name'];?></p></strong>
<input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer1'];?>
<br/>
<input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer2'];?>
<br/>
<input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer3'];?>
<br/>
<input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer4'];?>
<br/>
<input type="radio" checked='checked' style='display:none' value="5" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/>
<br/>
<div id="botones" class="mm-survey-controller">
<div class="mm-prev-btn">
<button id='<?php echo $i;?>' class='previous' type='button'>Anterior</button>
</div>
<div class="mm-next-btn">
<button id='<?php echo $i;?>' class='next' type='submit'>Finalizar</button>
</div>
</div>
</div>
<?php } $i++;} ?>
</form>
if(isset($_POST[1])){
$keys=array_keys($_POST);
$order=join(",",$keys);
$response=mysql_query("select id,answer from $bd where id IN($order) ORDER BY FIELD(id,$order)") or die(mysql_error());
$right_answer=0;
$wrong_answer=0;
$unanswered=0;
$r = 0;
while($result=mysql_fetch_array($response)){
if($result['answer']==$_POST[$result['id']]){
$right_answer++;
}else if($_POST[$result['id']]==5){
$unanswered++;
}else{
$wrong_answer++;
${'x'.$r} = $result['id'];
echo $x[$r];
$r++;
}
}
echo "right_answer : ". $right_answer."<br>";
echo "wrong_answer : ". $wrong_answer."<br>";
echo "unanswered : ". $unanswered."<br>";
}