0

我有reservationpostflight表。我必须在表中进行查询并在reservation表中查找数据postflight

$query="select * from reservation where date(fdate) between '$datefrom' and '$dateto' and status in ('Flown') $aircraft order by $sort";
$result=mysql_query($query) or die(mysql_error());  
echo "<div class='box'><table class='hovertable'>
    <th>Flight Date</th> 
    <th>Client Name</th> 
    <th>Group Code</th>
    <th>Aircraft</th>
    <th>Block Time</th>
    <th>Waiting Time</th>
    <th>Charter Fee</th>
    <th>Take-off and Landing Fee</th>
    <th>Waiting Time Fee</th>
    <th>Other Charges</th>
    <th>Sub-Total</th>
    <th>Value-added Tax</th>
    <th>Total Service Invoice Amount</th>
    <th>Reservation No.</th>
    </tr>";

while($row=mysql_fetch_array($result))
{
    $rvno=$row['reservno'];
    $yr=(string) date("Y");
    $rn=$yr."-".$rvno;
    $a=mysql_query("select *, (fdf + fce + aef + hf + sfp) as 'tcharge' from postflight where reservno='$rvno'") or die(mysql_error());
    //$e=mysql_fetch_array($a);
    while($b=mysql_fetch_array($a))
    {
    echo"<tr><td>".$row['fdate']."</td><td>".$b['cliename']."</td><td>".$row['grpcode']."</td><td>".$row['acode']."</td><td>".$row['btime']."</td><td>".$b['wtime']."</td><td>".$b['total_cfee']."</td><td>".$b['total_tol']."</td><td>".$b['total_wtfee']."</td><td>".$b['tcharge']."</td><td>".$b['sub_total']."</td><td>".$b['vat']."</td><td>".$b['total_service_invoice_amt']."</td><td>".$rn."</td></tr>";
    }

}

在我关闭之前</table>,我想添加另一行,它根据上面查询的输出数据汇总所有需要汇总的字段。就像是,

echo "<tr><td colspan='6'></td><td><b>sum</b></td><td><b>sum</b></td><td><b>sum</b></td><td><b>sum</b></td><td><b>sum</b></td><td><b>sum/b></td><td><b>sum</b></td><td></td></tr>";

但我不知道该怎么做。请帮忙。谢谢。

4

1 回答 1

0

你可以这样做:

$sum = 0;
while($b=mysql_fetch_array($a))
{
    //your codes

    $sum += $fields //fields you want to sum up

    echo "<tr><td> 'Sum:'. $sum ... </td></tr>";
}

echo "</table>";

于 2013-05-22T02:50:31.107 回答