gpt4 book ai didi

mysql - 汇总查询结果

转载 作者:行者123 更新时间:2023-11-30 01:37:22 25 4
gpt4 key购买 nike

我有reservationpostflight table 。我必须在 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>";

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

最佳答案

你可以这样做:

$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>";
<小时/>

关于mysql - 汇总查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16682665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com