我将表单数据发送到 php 页面,例如: question1 question2 。. . 和更多。
我想总结这些变体,但我不知道。我使用此代码但不起作用:
$total=0;
for ($i=1; $i<=$countc; $i++) {
$sag = "question" . $i;
$_POST[$sag];
$total = $total+$_POST[$sag];
echo $total; // I wanna show sum of all form vars.
}
我的表格:
echo "
<form method='post' action='result.php?result=$name' />
<input name='$name' style='visibility:hidden' /><br />
";
for ($i=0;$i<$countq;$i++){
echo "${'countquestion'.$i}<br />";
for ($j=0;$j<$countc;$j++){
echo "${'countchoice'.$j.'countquestion'.$i}
<input type='radio' value='${'countchoicepoint'.$j.'countquestion'.$i}' name='question$i' /><br />
";
}
}
echo "
<input type='submit' value='sabt' />
";