我有一个 PHP 页面,显示带有单选按钮的 MySQL 查询的总数。这是在一个表格里面。用户应该选择一个单选按钮来填写所有表格,然后总数将存储在数据库中,我想将所选单选按钮的总值传递到下一页并打印出来。
我知道这很容易,但我不能正确地提出解决方案。
我的 PHP 页面代码如下:
<?php
session_start();
$Load=$_SESSION['login_user'];
include('../connect.php');
$sql= "Select name from student where ID='$Load'";
$username = mysql_query($sql);
$id=$_SESSION['login_user'];
if (isset($_POST['submit']))
{
$v1 = $_POST['v1'];
$v2 = intval($_POST['v2']);
$v3 = intval($_POST['v3']);
$v4 = intval($_POST['v4']);
$total = $2 + $v3 + $v4 ;
mysql_query("INSERT into Form1 (ID,P1,P2,P3,TOTAL)
values('$id','$v2','$v3','$v4','$total')") or die(mysql_error());
header("Location: mark.php");
}
?>
<html>
<head>
<?php
if(!isset($_SESSION['login_user']))
header("Location:index.html");
?>
<title>Q&A Form</title>
</head>
<body>
<center><form method="post" action="mark.php" >
<table style="width: 20%" >
<font size='4'>
<table style="width: 70%">
<tr>
<th > School Evaluation <font size="4" > </font></th>
<tr>
<th> Your attendance<font size="4" > </font></th>
<td> <input type="radio" name ="v2" value = "4" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v2" value = "3" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v2" value = "2" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v2" value = "1" onclick="updateTotal();" /></td>
</tr>
<tr>
<th > Your grades <font size="4" > </font></th>
<td> <input type="radio" name ="v3" value = "4" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v3" value = "3" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v3" value = "2" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v3" value = "1" onclick="updateTotal();" /></td>
</tr>
<tr>
<th >Your self-control <font size="4" > </font></th>
<td> <input type="radio" name ="v4" value = "4" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v4" value = "3" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v4" value = "2" onclick="updateTotal();" /></td>
<td> <input type="radio" name ="v4" value = "1" onclick="updateTotal();" /></td>
</tr>
</tr>
</table>
<br>
<td><input type="submit" name="submit" value="Submit">
<input type="reset" name="clear" value="clear" style="width: 70px"></td>
</form>
</center>
</div>
</body>
</html>
当用户按下提交时,所有无线电输入将存储在数据库中,它将转到 mark.php 我想在此页面中打印出总数如何将总数传递到下一页?