我想显示数据库中的数据。我想显示4个名为'得分',' listening_score',' reading_score'和' structure_score'。 '得分'表包含最终得分。
的index.php
<? php
echo "Your TOEFL Score, <br>";
echo "<table class=\"score\">";
$email = $_SESSION['email'];
$q = mysql_query("SELECT * FROM score where email='$email'");
$query = mysql_query("SELECT * FROM structure_score where email='$email'");
$query1 = mysql_query("SELECT * FROM listening_score where email='$email'");
$query2 = mysql_query("SELECT * FROM reading_score where email='$email'");
while ($row = mysql_fetch_array($q)) {
echo "
<h3> <span >".$row['Score']."</span> </h3>";
while ($row = mysql_fetch_array($query)) {
echo "
<tr><td>Score Structure: </td> <td>".$row['Score']."</td><td>Right Answer: </td> <td>".$row['Right_Answer']."</td></tr>";
while ($row = mysql_fetch_array($query1)) {
echo "
<tr><td>Score Listening: </td> <td>".$row['Score']."</td><td>Right Answer: </td> <td>".$row['Right_Answer']."</td></tr>";
while ($row = mysql_fetch_array($query2)) {
echo "
<tr><td>Score Reading: </td> <td>".$row['Score']."</td><td>Right Answer: </td> <td>".$row['Right_Answer']."</td></tr>";
}
}
}
}
echo "</table><br><br>";
?>
我想要显示:
233
Score Structure: 24 Right Answer: 0
Score Listening: 24 Right Answer: 0
Score Reading: 22 Right Answer: 0
但是,当我测试两次时,数据将显示如下:
233
263
Score Structure: 24 Right Answer: 0
Score Listening: 24 Right Answer: 0
Score Reading: 22 Right Answer: 0
Score Reading: 31 Right Answer: 12
Score Listening: 33 Right Answer: 10
Score Structure: 32 Right Answer: 8
我想这样显示:
233
Score Structure: 24 Right Answer: 0
Score Listening: 24 Right Answer: 0
Score Reading: 22 Right Answer: 0
263
Score Reading: 31 Right Answer: 12
Score Listening: 33 Right Answer: 10
Score Structure: 32 Right Answer: 8
这是我的表结构:
CREATE TABLE IF NOT EXISTS `score` (
`email` varchar(30) NOT NULL,
`Score` int(100) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `listening_score` (
`email` varchar(30) NOT NULL,
`Right_Answer` int(100) NOT NULL,
`Score` int(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `reading_score` (
`email` varchar(30) NOT NULL,
`Right_Answer` int(100) NOT NULL,
`Score` int(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `structure_score` (
`email` varchar(30) NOT NULL,
`Right_Answer` int(100) NOT NULL,
`Score` int(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;