我在更新由带有类型单选按钮的问题组成的表单来回答它时遇到问题,我尝试了很多,但是当我选择新按钮时它不会改变数据库中的任何内容。
对于提交我使用
if (isset($_POST['submit']))
{
$v1 = intval($_POST['v1']);
$v2 = intval($_POST['v2']);
$v3 = intval($_POST['v3']);
$v4 = intval($_POST['v4']);
$v5 = intval($_POST['v5']);
$v6 = intval($_POST['v6']);
$v7 = intval($_POST['v7']);
$v8 = intval($_POST['v8']);
$total = $v1 + $v2 + $v3 + $v4 + $v5 + $v6 + $v7 + $v8 ;
$Percentage = $total / 32 * 10 ;
mysql_query("UPDATE grades_presentation SET P1='$v1',P2='$v2',P3='$v3',P4='$v4',P5='$v5',P6='$v6',P7='$v7',P8='$v8',TOTAL='$total',Percentage='$Percentage' WHERE SID='$id' ") or die(mysql_error());
header("Location: mark.php");
这是其中一个问题,我使用 Checked 来告诉我哪个按钮用户已经检查了!
<tr>
<th bgcolor='FF6600'> Clarity of speaking
(Could you hear the speaker properly and clearly?)<font size="4" > </font></th>
<td> <input type="radio" name ="v1" value = "4" <?php echo ($v1=='4')?'checked':'' ?> onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v1" value = "3" <?php echo ($v1=='3')?'checked':'' ?> onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v1" value = "2" <?php echo ($v1=='2')?'checked':'' ?> onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v1" value = "1" <?php echo ($v1=='1')?'checked':'' ?> onclick="updateTotal();" /></td>
</tr>