-5
我有這個表:PHP合併行(多列)
Material Number | BPM Number | STTPP Number | Qty
A | 123 | 1231 | 100
A | 123 | 1232 | 200
B | 234 | 2341 | 100
B | 234 | 2342 | 100
C | 432 | 4321 | 100
D | 567 | 5671 | 100
D | 567 | 5672 | 600
D | 568 | 5681 | 300
D | 568 | 5682 | 200
D | 598 | 5981 | 100
D | 598 | 5672 | 90
,並試圖顯示它看起來就像這樣:
Material Number | BPM Number | STTPP Number | Qty
A | 123 | 1231 | 100
| | 1232 | 200
B | 234 | 2341 | 100
| | 2342 | 100
C | 432 | 4321 | 100
D | 567 | 5671 | 100
| | 5672 | 600
| 568 | 5681 | 300
| | 5682 | 200
| 598 | 5981 | 100
| | 5672 | 90
到處搜尋,但我發現,他們只合並第一列... 這是我迄今所做的:
<?php
$query="SELECT * FROM sttpp_item_list order by material_code";
$proses=mysql_query($query);
$i=0;
while($data=mysql_fetch_assoc($proses))
{
$row[$i]=$data;
$i++;
}
foreach($row as $cell)
{
if(isset($total[$cell['material_code']]['quantity_dely']))
{
$total[$cell['material_code']]['quantity_dely']++;
}
else
{
$total[$cell['material_code']]['quantity_dely']=1;
}
}
echo "<table border=\"1\">
<tr>
<th>Material Number</th>
<th>BPM Number</th>
<th>STTPP Number</th>
<th>STTPP Number</th>
</tr>";
$n=count($row);
$cekmaterial_code="";
for($i=0;$i<$n;$i++)
{
$cell=$row[$i];
echo '<tr>';
if($cekmaterial_code!=$cell['material_code'])
{
echo '<td' .($total[$cell['material_code']]
'quantity_dely']>1?' rowspan="' .
($total[$cell['material_code']]['quantity_dely']).'">':'>')
.$cell['material_code'].'</td>';
$cekmaterial_code=$cell['material_code'];
}
echo "<td>$cell[bpm_number]</td><td>$cell[quantity_dely]
</td>";
echo "</tr>";
}
echo "</table>";
?>
此代碼資源ult:
材料號| BPM編號| STTPP號碼|數量
A | 123 | 1231 | 100
| 123 | 1232 | 200
B | 234 | 2341 | 100
| 234 | 2342 | 100
C | 432 | 4321 | 100
D | 567 | 5671 | 100
| 567 | 5672 | 600
| 568 | 5681 | 300
| 568 | 5682 | 200
| 598 | 5981 | 100
| 598 | 5672 | 90
任何建議?請幫忙...
到目前爲止您嘗試過了什麼?任何代碼? –
請添加原始格式化的代碼,而不是圖像 – OldPadawan
甚至不能在這裏創建一個表...對不起,... –