我有这个工作。
SUM('pagesat')
我需要为特定日期计算的总行数。
我还需要<table class="responsive-table">
<thead>
<tr>
<th>Vetura</th>
<th>Targa</th>
<th>Dite</th>
<th>Pagesa</th>
<th>Cmimi Ditore</th>
<th>Vazhdim</th>
<th>Te Tjera</th>
<th>Shpenzime</th>
<th>Komente</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM `raport` WHERE DATE(`timestamp`) = CURDATE() AND (lokacioni = 'FR')";
$stmt = $DBcon->prepare( $query );
$stmt->execute();
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
?>
<tr>
<td><?php echo $row['vetura']; ?></td>
<td><?php echo $row['targa']; ?></td>
<td><?php echo $row['dite']; ?></td>
<td><?php echo $row['pagesa']; ?>€</td>
<td><?php echo $row['cmimiditore']; ?>€</td>
<td><?php echo $row['vazhdim']; ?>€</td>
<td><?php echo $row['tetjera']; ?>€</td>
<td><?php echo $row['shpenzime']; ?>€</td>
<td><?php echo $row['koment']; ?></td>
</tr>
<?php
$pagesa = $row['pagesa'];
$tetjera = $row['tetjera'];
$vazhdime = $row['vazhdim'];
$shpenzime = $row['shpenzime'];
}?>
</tbody>
</table>
<?php
$totali = ($pagesa + $vazhdime + $tetjera);
$gtotal = ($totali - $shpenzime);
?>
<div class="card grey">
<hgroup class="totalDitorRaport">
<h2>Total</h2>
<h1><?php echo $gtotal; ?>€</h1>
</hgroup>
</div>
以某种方式,但我不知道如何。
查找下面的完整代码。
我正在努力建立一些简单的东西,以显示我们拥有的3个地点的收入和结果。
No. Date
1 1992-08-25 00:00:00.000
2 2015-05-19 00:00:00.000
3 2000-01-12 00:00:00.000
答案 0 :(得分:2)
试试这个
获取循环中行pagesa
的总和
$queryPR = "SELECT * FROM `raport` WHERE DATE(`timestamp`) = CURDATE() AND (lokacioni = 'PR')";
$stmt = $DBcon->prepare( $query );
$stmt->execute();
$sum = 0;
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
$sum += $row['pagesa'];
}
echo $sum;