เอามาโชว์เป็น report ซึ่งข้อมูลที่ดึงได้มันจะซ้ำกัน
โค้ด: เลือกทั้งหมด
<table align="center" class="display reporttable" id="cost_table" name="cost_table">
<thead>
<tr>
<th rowspan="3" class="ui-state-default">CenterNo.</th>
<th rowspan="3" class="ui-state-default">Function Code</th>
<th colspan="<? echo $maxloop; ?>" class="ui-state-default">DeviceType</th>
<th rowspan="3" class="ui-state-default">ค่าเช่าต่อเดือน</th>
<th rowspan="3" class="ui-state-default">ค่าเช่าต่อปี</th>
<th rowspan="3" class="ui-state-default">ค่าเช่าต่อ3ปี</th>
</tr>
<tr>
<?php for($i=0;$i<$maxloop;$i++)
{
?>
<th class='ui-state-default'><? echo $Equipment_Type[$i]; ?></th> <?php } ?>
</tr>
<tr>
<?php for($i=0;$i<$maxloop;$i++)
{
if($act[$i] == 0){
$price = $budget;
}
else{
$price = $act;
}
?>
<th class="ui-state-default"><? echo $price[$i];?></th> <?php } ?>
</tr>
</thead>
<tbody>
<?php
$idcontract = $_GET['selcontract'];
include "connect.php";
$conn->open($msaccdb);
$str1 = "SELECT tb_Equipment.*, tb_Purchase.* ,tb_Function.* , tb_Center_Function.* , tb_Center.*
FROM tb_Equipment, tb_Purchase , tb_Function , tb_Center_Function , tb_Center
WHERE tb_Equipment.ID_Equipment = tb_Purchase.ID_Equipment
AND tb_Equipment.ID_Contract = $idcontract
AND tb_Function.ID_Function = tb_Purchase.ID_Function
AND tb_Center_Function.ID_Function = tb_Function.ID_Function
AND tb_Center_Function.ID_Center = tb_Center.ID_Center
ORDER BY tb_Center.CenterNo ASC";
$Rec->Open($str1, $conn, 1, 3);
$maxloop = $Rec->RecordCount();
while (!$Rec->EOF)
{
$FunctionCode = $Rec->Fields['Function_Name']->Value;
$budgetnew = $Rec->Fields['Budget_New']->Value;
$budgetre = $Rec->Fields['Budget_Replace']->Value;
$budgetrecon = $Rec->Fields['Budget_Replace_Contract']->Value;
$actnew = $Rec->Fields['Act_New']->Value;
$actre = $Rec->Fields['Act_Replace']->Value;
$actrecon = $Rec->Fields['Act_Replace_Contract']->Value;
$CenterNo = $Rec->Fields['CenterNo']->Value;
?>
<tr >
<td><? echo $CenterNo; ?></td>
<td><? echo $FunctionCode; ?></td>
<td><? echo $Purchase; ?></td>
<td><? echo $RentMonth; ?></td>
<td><? echo $RentYear; ?></td>
<td><? echo $Rent3Year; ?></td>
</tr>
<? $Rec->MoveNext();
}
$Rec->Close();
?>
</tbody>
</table>