我怎样才能显示所有除法分开的总数?
例子:
我想要这样的数据
---------------------------------------------------------------
CARD NO NAME CAR NO DIVISION DATE AMOUNT
---------------------------------------------------------------
80351 MANWATERTANKER 4454HM 102 2013-9-30 95.000
60759 TIPPER 2368BK 102 2013-8-31 77.500
64545 MFASIL 3334HG 102 2013-9-30 20.000
56565 XYAZ 93F68K 102 2013-8-31 55.000
---------------------------------------------------------------
Total 247.500
---------------------------------------------------------------
CARD NO NAME CAR NO DIVISION DATE AMOUNT
---------------------------------------------------------------
90178 ATEEQ 8931RR 105 2013-7-31 551.000
43325 USMAN 6732YY 105 2013-6-30 12.500
55598 ALAAM 4631TT 105 2013-7-31 158.000
---------------------------------------------------------------
Total 721.500
---------------------------------------------------------------
CARD NO NAME CAR NO DIVISION DATE AMOUNT
---------------------------------------------------------------
40678 FATHISALIM 1632AM 103 2013-6-30 454.440
---------------------------------------------------------------
Total 454.440
-----------------------------------------------------------------
AND OVERALL TOTAL 1423.440
-----------------------------------------------------------------
现在它是这样显示的
---------------------------------------------------------------
CARD NO NAME CAR NO DIVISION DATE AMOUNT
---------------------------------------------------------------
80351 MANWATERTANKER 4454HM 102 2013-9-30 95.000
60759 TIPPER 2368BK 102 2013-8-31 77.500
40678 FATHISALIM 1632AM 103 2013-6-30 454.440
90178 ATEEQ 8931RR 105 2013-7-31 551.000
64545 MFASIL 3334HG 102 2013-9-30 20.000
56565 XYAZ 93F68K 102 2013-8-31 55.000
43325 USMAN 6732YY 105 2013-6-30 12.500
55598 ALAAM 4631TT 105 2013-7-31 158.000
---------------------------------------------------------------
Total 1423.440
这是我的代码:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("car", $con);
function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}
$a=$_POST['from'];
$b=$_POST['to'];
echo "<span align='center' class='style2'>Report For The Period Of $a to $b</span>";
echo "<div id='non-printable'><table class='hovertable' border='1' cellpadding='10'>";
echo "<tr> <th>CardNo</th> <th>NAME/th><th>CARNO</th><th>Division</th> <th>Date</th><th>AMOUNT</th></tr>";
// get results1 from database
$result1 = mysql_query("SELECT * FROM fuel where date BETWEEN '$a' AND '$b' order by division ASC");
while($row = mysql_fetch_array($result1))
{
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['cardno'] . '</td>';
echo '<td>' . $row['drivernamefuel'] . '</td>';
echo '<td>' . $row['carno'] . '</td>';
echo '<td>' . $row['division'] . '</td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['amount'] . '</td>';
echo "</tr>";
//Increment the value of the Total_total variable
//by the salary value of one row till the while loop finishes
$Total_amount=$Total_amount+$row['amount'];
}
echo "<tr>";
echo '<td>Total</td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td>' . $Total_amount .'</td>';
echo "</tr>";
// close table>
echo "</table>";
mysql_close($con);
?>