gpt4 book ai didi

php - Bootstrap 表仅在 中显示一行

转载 作者:行者123 更新时间:2023-11-29 13:28:24 25 4
gpt4 key购买 nike

Table Error

( http://imgur.com/2Ev8u4L )

正如您从图像中看到的,表格中的第一行仅存在于实际表格中。我不确定这可能是代码错误?

$selectNews = $PDO->query("SELECT * FROM `news`");

echo '<table class="table">';
echo '<thead>';
echo '<th>Update Number</th>';
echo '<th>Title</th>';
echo '<th>Description</th>';
echo '<th>Created On</th>';
echo '<th>Created By</th>';
echo '</thead>';

while ($results = $selectNews->fetch(PDO::FETCH_ASSOC)) {
echo "<tbody>";
echo "<tr><td>";
echo $results['ID']."</td><td>";
echo $results['Title']."</td><td>";
echo $results['Description']."</td><td>";
echo date('d/m/Y g:i:s A', strtotime($results['Time']))."</td><td>";
echo $results['Creater']."</td></tr>";
echo "</tbody>";
echo "</table>";
}

最佳答案

您不会检查 $selectNews 是否确实有效。来自 PDO::query

Return Values
PDO::query() returns a PDOStatement object, or FALSE on failure.

更新:

您已将 tbodytable 放入 while 循环中。您必须将开始和结束标记放在

之外
echo "<tbody>";
while ($results = $selectNews->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>";
...
echo $results['Creater']."</td></tr>";
}

echo "</tbody>";
echo "</table>";

关于php - Bootstrap 表仅在 <td> 中显示一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19823861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com