【发布时间】:2023-03-15 20:24:01
【问题描述】:
我在使用 SQL 语句的结果和 PHP 的一些 HTML 布局打印时间表时遇到问题。
我在页面顶部有上课时间。 我试图将星期几放在页面的一侧,然后检查是否应在特定日期和时间打印 SQL 语句(包含模块)的结果。
//Print out the top of the array to display the times
echo "<div><table class='table table-bordered'><thead><tr><th></th><th>9-10</th><th>10-11</th><th>11-12</th><th>12-13</th><th>13-14</th><th>14-15</th><th>15-16</th><th>16-17</th></tr></thead><tbody>'";
//Now loop through the result of the SQL statement that contains the modules associated with the selected course
while($row = mysqli_fetch_array($result1)) {
for($d = 1; $d < 6; $d++){
$printday = $days[$d];
echo "$printday";
for($t = 9; $t < 17; $t++) {
if($row['Day'] == $d && $row['Time'] == $t){ //fix this area so that it moves along
echo "<td>" . $row['ModuleName'] . "<br/>\n " .$row['Location'] . "</td>";
} //if
else {
echo "<td></td>";
} //else
} //for 2
echo "</tr>";
} //for 1
} //while
问题是我在周一至周五打印了 3 次,因为有 3 个 $row 结果。任何想法我怎么能让这个工作。
【问题讨论】:
-
echo "<td></td>";应该是echo "<td>&nbsp;</td>";- 至于其余的,我不明白你想要做什么。 -
问题不是他的 HTML.. 只需将其删除为块并使用其中的内容。
-
@Pamblam 我敢打赌这些数字代表 9-5 个工作日
-
@Pamblam 顶部 9-5 个工作日。周一至周五下来。由于我有 3 个结果,它会将第一行发布在正确的位置,但随后会打印出其余的日子。然后它转到第二个结果并执行此操作。因此,而不是 5 天显示 3 个模块。我在周一至周五展示了 3 次(共 15 次)和 3 个模块