Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 引导表在<;中仅显示一行;td>;_Php_Html_Mysql_Sql_Twitter Bootstrap - Fatal编程技术网

Php 引导表在<;中仅显示一行;td>;

Php 引导表在<;中仅显示一行;td>;,php,html,mysql,sql,twitter-bootstrap,Php,Html,Mysql,Sql,Twitter Bootstrap,() 从图中可以看到,表中的第一行仅在实际表中。可能是代码错误,我不确定 $selectNews = $PDO->query("SELECT * FROM `news`"); echo '<table class="table">'; echo '<thead>'; echo '<th>Update Number</th>'; echo '<th>Title</th>'; echo '

()

从图中可以看到,表中的第一行仅在实际表中。可能是代码错误,我不确定

$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(“从“新闻”中选择*”;
回声';
回声';
回显“更新编号”;
呼应“标题”;
回声“描述”;
echo“创建于”;
回声“由”创建;
回声';
而($results=$selectNews->fetch(PDO::fetch_ASSOC)){
回声“;
回声“;
echo$results['ID']。“”;
echo$results['Title']。“”;
echo$results['Description']。“”;
回显日期('d/m/Y g:i:SA',实时($results['Time']));
echo$results['Creater']。“”;
回声“;
回声“;
}

如果
$selectNews
确实有效,则不进行检查。从

返回值
PDO::query()返回PDOStatement对象,或在失败时返回FALSE

更新:

您已将
t车身
表格
放入while循环中。你必须把开始和结束标签放在外面

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

echo "</tbody>";
echo "</table>";
echo”“;
而($results=$selectNews->fetch(PDO::fetch_ASSOC)){
回声“;
...
echo$results['Creater']。“”;
}
回声“;
回声“;

它显示了数据库中的所有行,正如您在图中所看到的,但是当我清楚地将第二行放在while循环中时,它不在表中。