我的电脑老师要我做一个简单的 php mySql 数据库多项选择测验,但现在我被卡住了。我已经制作了 input-form.php。因此,当他进入页面时,他可以输入问题和多项选择答案。到目前为止,我的工作是 input-form.php 和 quiz1.php,它们显示数据库中的内容。我现在需要有关如何使用多项选择答案旁边的单选按钮的帮助,以便学生可以阅读问题并单击正确的答案。在他们阅读并单击那里的选项后,当他们点击提交时,它将向老师发送一封测试电子邮件,其中包含问题和多项选择答案以及他们选择的答案。
测试:
What process determines the identity of a user?
A. Authentication
B. tt4ert4t
C. 4tt4t
D. 4tt4
Which of the following user account types can create other user accounts?
A. uyiyuiy
B. iuyiuiiu
C. Administrator
D. uykuykuyikuy
To which of the following groups does a standard user in Windows 2000 belong by default? (Select two.)
A. Limited Users
B. Power Users
C. Restricted Users
D. Users
等等 ....
php代码:
<?php
// connect to your MySQL database here
require_once "db_connect.php";
// Build the sql command string
$sqlCommand = "SELECT `question`, `a`, `b`, `c`, `d` FROM `quiz1`";
// Execute the query here now
$query = mysql_query($sqlCommand) or die (mysql_error());
// Output the data here using a while loop, the loop will return all members
while ($row = mysql_fetch_array($query)) {
// Gather all $row values into local variables for easier usage in output
$question = $row["question"];
$a = $row["a"];
$b = $row["b"];
$c = $row["c"];
$d = $row["d"];
// echo the output to browser
echo "$question
<br />A. $a
<br />B. $b
<br />C. $c
<br />D. $d
<br /><hr />";
}
// Free the result set if it is large
mysql_free_result($query);
// close mysql connection
mysql_close();
?>