从数组中加倍回显表格
问题描述:
根据用户选择的选项,可以有不同的数字。因此,我创建了一个函数,它将从两个数组中生成一个表格。第一个是列标题的名称,第二个是实际的数据。这是我的函数:从数组中加倍回显表格
function terminalTables ($numCol, $tableName, $data, $colName, $aircraft, $servicePack){
echo '<h3> Tail: '.$aircraft.'<br> Service pack: '.$servicePack.'</h3>';
echo '<table id="'.$tableName.'" cellpadding="2" cellspacing="2" style="text-align:center;" class="db-table db-table dTableWidth dataTable no-footer">';
echo '<thead>';
foreach ($colName as $col){
echo '<th scope="col" style="white-space:nowrap">column:'.$col.'<th>';
}
/*for ($ii = 0; $colName[$ii] != NULL; $ii++){
echo "<script>alert(\"column name: $colName[$ii]\");</script>";
echo '<th scope="col" style="white-space:nowrap">'.$colName[$ii].'<th>';
}*/
echo '</thead>';
echo '<tbody>';
for ($iii = 0; $data[$iii] != NULL; $iii++){
echo '<tr>';
for ($j = 0; $j < $numCol; $j++){
echo "<td style='white-space:nowrap; padding-left:1em; padding-right:1em;'>".$data[$iii][$j].'</td>';
}
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
exit; }
所有被正确显示的数据,但是列数在THEAD被复制
当我们检查的表头元素,这就是我们得到:
<table id="datatable" class="db-table db-table dTableWidth dataTable no-footer" style="text-align:center;" cellspacing="2" cellpadding="2">
<thead>
<tr>
<th scope="col" style="white-space:nowrap">column:Event Time</th>
<th></th>
<th scope="col" style="white-space:nowrap">column:Event Type</th>
<th></th>
<th scope="col" style="white-space:nowrap">column:Rx Bytes Since power on (KB)</th>
<th></th>
<th scope="col" style="white-space:nowrap">column:Tx Bytes Since power on (KB)</th>
<th></th>
<th scope="col" style="white-space:nowrap">column:Link Start Time</th>
<th></th>
</tr>
</thead>
请注意,在每个实际列前,我们有列:命名。我们共有5个实际的专栏和5个。正因为如此,我的桌子完全被推到了一边。
我一直在试图调试这太长时间,现在我的头很痛。我做错了什么?非常感谢你。
找出我的错误,我很生气。这是我原本的代码:
echo '<th scope="col" id="terminalTables">'.$col.'<th>';
请注意,在行末,我没有一个but。是的,我是个白痴。 它应该一直是这样的:!
echo '<th scope="col" id="terminalTables">'.$col.'</th>';
答
找出我的错误,我很生气。这是我原本的代码:
echo '<th scope="col" id="terminalTables">'.$col.'<th>';
请注意,在行末,我没有一个but。是的,我是个白痴。 它应该一直是这样的:!
echo '<th scope="col" id="terminalTables">'.$col.'</th>';
''
'$数据[$ III] = NULL;'也许应该是'$ iii
bassxzero
这是真的我忘了
回答
找出我的错误,我很生气。这是我原本的代码:
请注意,在行末,我没有一个but。是的,我是个白痴。 它应该一直是这样的:!
相关问题