i want to display data from database. i want to display 4 tables named 'score', 'listening_score', 'reading_score' and 'structure_score'. 'score' table contained final 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>";
?>
i want to display:
233
Score Structure: 24 Right Answer: 0
Score Listening: 24 Right Answer: 0
Score Reading: 22 Right Answer: 0
BUT when i test twice, data will be displaying like this:
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
I want to display like this:
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
this is my table structure:
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;