【发布时间】:2020-09-29 13:26:53
【问题描述】:
我目前正在从 Oracle 表中循环 SQL 结果。表中的所有行都返回正常,但是它们都停留在元素内,而不是像下面这样的新行
这是我当前的表...
<div id="smtTable" class="targetDiv">
<table width="40%" style="margin: 0 auto; border:1px solid;text-align:center; width: auto;" class="table table-sm table-dark">
<tr>
<th scope="col">Area</th>
<th scope="col">Week 18</th>
<th scope="col">Week 19</th>
<th scope="col">Week 20</th>
<th scope="col">Week 21</th>
<th scope="col">Week 22</th>
</tr>
<?php
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
}
?>
【问题讨论】:
-
您需要为每行数据添加行标签。只需将
<tr>(和结束标签)添加到while循环中。 -
新行不需要
元素吗?