用SQL数据和PHP填充HTML表
我正在尝试使用几个循环填充一个表 第一个循环用一行中的用户填充表头,这没有问题 问题是将tds填充为具有正确票证号的行 我可以在一个td中获得订单列中的所有数字,这不是它应该如何工作的 像这样的,用SQL数据和PHP填充HTML表,php,html,for-loop,html-table,Php,Html,For Loop,Html Table,我正在尝试使用几个循环填充一个表 第一个循环用一行中的用户填充表头,这没有问题 问题是将tds填充为具有正确票证号的行 我可以在一个td中获得订单列中的所有数字,这不是它应该如何工作的 像这样的, --------------------- user1 | user2 | user3 --------------------- 00001 | 00004 | 00007 00002 | 00005 | 00008 00003 | 00006 | 00009 -------------------
---------------------
user1 | user2 | user3
---------------------
00001 | 00004 | 00007
00002 | 00005 | 00008
00003 | 00006 | 00009
---------------------
应该是,
---------------------
user1 | user2 | user3
---------------------
00001 | 00004 | 00007
---------------------
00002 | 00005 | 00008
---------------------
00003 | 00006 | 00009
---------------------
你明白了
这是我用的代码
<table class="table table-hover">
<thead>
<tr>
<th scope="row">
<?php
$userName = functionName();
for ($userName->rewind(); $userName->pointer < $userName->size; $userName->next()) {
$record = $userName->current();
$firstName = $record->fields->FirstName;
?>
<th><?php echo $firstName; ?></th>
<?php } ?>
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<?php
for ($userName->rewind(); $userName->pointer < $userName->size; $userName->next()) {
$record = $userName->current();
$firstName = $record->fields->FirstName;
?>
<td>
<?php
$userCase = functionCase($firstName);
for ($userCase->rewind(); $userCase->pointer < $userCase->size; $userCase->next()) {
$record = $userCase->current();
$caseNumber = $record->fields->CaseNumber;
$status = $record->fields->Status;
echo $caseNumber;
?>
<?php }
?>
</td>
<?php } ?>
</th>
</tr>
</tbody>
</table>
我想我可能使用了错误的逻辑和循环
你知道如何获得正确的表格结果吗?我认为你使用的HTML表格布局不正确
你有一个td在th内,据我所知这是不允许的。如果要在多行中显示数据,则必须为每行创建一个tr。然后,trs可以包含th和td项。有关有效的表格布局,请参阅,它与我已经使用的基本表格结构相同。但是谢谢。