In one of my scripts I have this code:
PHP Code:
$set_num = 0;
while ( $answers[$set_num] != "" )
{
if ( $answers[$set_num] == $actual_answer )
{
$results[$set_num]++;
}
$set_num++;
}
unset($set_num);
Currently
$answers[] contains 3 values but this may change depending on the results it pulls from the database earlier in the script.
As an example (because I'm not very good at explaining

):
$answers[0] = Yes;
$answers[1] = No;
$answers[2] = Don't know;
$results[0] = 2;
$results[1] = 7;
$results[2] = 3;
$actual_answer contains the data submitted by the user. Basically I want 1 to be added to one of the
$results[] when the corresponding
$answer[] is submitted. This script works for
$result[0] and
$result[1] but when the user selects the answer corresponding to
$answers[2],
$results[2] does not get 1 added to it's value.
Why does this happen and how can I fix it?