我的代码目前是这样的:
if (isset($_POST['viewstudentdrop'])) {
$query = "SELECT students.*, lessons.lessonname
FROM lessons INNER JOIN
(assignments INNER JOIN students
ON assignments.studentid = students.id)
ON lessons.lessonid = assignments.lesson
WHERE (((students.id)=".$_POST['viewstudentdrop']."))";
$results = $pdodl->query($query);
while ($row = $results->fetch()) {
echo "<p>Lesson: ". $row['lessonname'] . "</p>";
}
// View Completed Lessons and Times
$query = "SELECT *
FROM studentresponse
WHERE studentid = ".$_POST['viewstudentdrop']."
ORDER BY lessonsession";
$results = $pdodl->query($query);
echo '<table> ';
while ($row = $results->fetch()) {
echo '<tr> <td> ' . $row['actiontime'] .'</td>' .
' <td> ' . $row['page'] .'</td>' .
' <td> ' . $row['response'] . '</td>'.
' <td> '. $row['lessonsession'] . '<td> </tr>';
}
echo '</table>';
}
它会产生如下输出:
19:40:44 sda02 C 11360611641
19:40:46 sda03 D 11360611641
19:40:50 sda04 3 11360611641
19:40:53 sda05 A 11360611641
19:41:22 sda02 B 11360611678
19:41:24 sda03 C 11360611678
19:41:31 sda04 5 11360611678
19:41:34 sda05 B 11360611678
20:00:39 sda02 B 11360612836
20:00:41 sda03 C 11360612836
20:00:44 sda04 3 11360612836
20:00:47 sda05 B 11360612836
我可以将上面格式化的数据直接从数据库输出到表中,但我想将其输出为表,例如(被课程会话打破):
sda02 sda03 sda04 sda05
19:40:44 19:40:46 19:40:50 19:40:53
C D 3 A
sda02 sda03 sda04 sda05
19:41:22 19:41:24 19:41:31 19:41:34
B C 5 B
.... 等下一节课组。
之前可能一直很困惑。希望这有助于澄清我的问题。谢谢!