Hi, do I get it right that the data is coming from a form with n being a (variable) number of questions named q1, q2, ..., qn?
If so, you might think about changing the form so that the names are q[0], q[1], ..., q[n-1], or even easier name them all q[] - either way, the data would arrive as array then, which is easier to handle, something like
while($n < count($_POST['q'])):
$question = $_POST['q'][$n];
// ...
$n++;
}