我目前正在從 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"; } } ?>
1 回答

蕪湖不蕪
TA貢獻1796條經驗 獲得超7個贊
您需要關閉table并添加tr它的行標記:
<?php
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo '<tr>';
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo '</tr>';
}
echo '</table>';
?>
- 1 回答
- 0 關注
- 185 瀏覽
添加回答
舉報
0/150
提交
取消