【发布时间】:2018-01-31 04:38:39
【问题描述】:
不确定这是否是最好的方法.. 但是..
我有一个 PHP 文件调用 API 并执行 foreach 循环来获取我想要的所有数据。以前我是从我的 html 文件中调用它并将其放入表中,问题是它在技术上都显示为同一行,这使得格式化变得困难。
这是我曾经拥有的:
<div class="bgimg2 w3-container">
<table class="w3-table w3-medium w3-text-white">
<tr class="w3-blue-gray">
<th> <h5> Name </h5> </th>
<th> <h5> Size </h5> </th>
<th> <h5> % </h5> </th>
</tr>
<tr>
<th> <h4> <div id=queue> </h4> </th>
<th> <h4> <div id=queueSize> </h4> </th>
<th> <h4> <div id=queuePercent> </h4> </th>
</tr>
</thead>
</table>
</div>
我想让每个项目都显示为它自己的行,所以我尝试直接在表中执行 php foreach 循环。
这是我目前为桌子准备的:
<table class="w3-table w3-medium w3-text-white">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php
require_once ('/api/sabapiQueue.php');
foreach ($apiResultDataShift as $row){
?>
<tr>
<td> <?php $row['filename'] ?> </td>
</tr>
<?php } ?>
</tbody>
</table>
它不工作,文件甚至没有加载。不知道我哪里出错了。
任何帮助将不胜感激。
【问题讨论】:
-
Previously I was calling this from my html file and putting it into a table还是 HTML 文件吗? -
sabapiQueue.php中有什么内容?文件是否存在.php或.html?请在此处添加echo:<?php echo $row['filename']; ?> -
主要的事情在我面前跳出来......这不是
echo声明:<?php $row['filename'] ?>
标签: php html arrays foreach html-table