Forum Moderators: coopster
<?php
mysql_connect("localhost","root","");
mysql_select_db('oodb') or die( "Unable to select database");
$query=" SELECT * FROM oocust WHERE payrec = 'P'AND pd = ' '";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo date("m/d/Y") . "<br />";
echo "<font size=+2><b> Old Orchard Plumbing A/P Due Report</font></b></b><br />";
echo "<table cellspacing=1 cellpadding=0 border=0>
<tr>
<th colspan=2></th>
<th align=left>order</th>
<th>days</th>
<th>ship</th>
<th></th>
<tr>
<th>Inv#</th>
<th>Customer</th>
<th align=left>date</th>
<th>late</th>
<th>amt</th>
<th align=right>Charges</th>
<th align=right>tax</th>
<th align=right>Owed</th>
<tr>
<TH colspan=9>=======================================================================</TH>
</tr>";
while($row = mysql_fetch_array($result))
{
$totcharges = $totcharges + $row['charges'];
$tottax = $tottax + $row['tax'];
$totamtdue = $totamtdue + $row['amtdue'];
$totship = $totship + $row['shipamt'];
echo "<tr>";
echo "<td>" . $row['invnum'] . "</td>";
echo "<td>" . $row['bname'] . "</td>";
echo "<td>" . $row['dateord'] . "</td>";
echo "<td align=right>" . $row['dayslate'] . "</td>";
echo "<td align=right>" . $row['shipamt'] . "</td>";
echo "<td align=right>" . $row['charges'] . "</td>";
echo "<td align=right>" . $row['tax'] . "</td>";
echo "<td align=right>" . $row['amtdue'] . "</td>";
}
echo "<tr>";
echo "<th colspan=9>=======================================================================</TH>";
echo "<tr>";
echo "<td>Gtotals</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td align=right>" . sprintf("%.2f",$totship) .
"</td>";
echo "<td align=right>" . sprintf("%.2f",$totcharges) .
"</td>";
echo "<td align=right>" . sprintf("%.2f",$tottax) .
"</td>";
echo "<td align=right>" . sprintf("%.2f",$totamtdue) .
"</td>";
echo "</tr>";
echo "</table>";
mysql_close();
?> Notice: Undefined index: totcharges in C:\xampp\htdocs\invoice\apdue.php on line 7
Notice: Undefined index: tottax in C:\xampp\htdocs\invoice\apdue.php on line 8
Notice: Undefined index: totamtdue in C:\xampp\htdocs\invoice\apdue.php on line 9
Notice: Undefined index: totship in C:\xampp\htdocs\invoice\apdue.php on line 10
08/13/2011
Old Orchard Plumbing A/P Due Report
order days ship
Inv# Customer date late amt Charges tax Owed
=======================================================================
154 kennys machine shop 10/15/2010 270 0.00 5.35 0.31 5.66
=======================================================================
Gtotals
$totcharges = 0;
$tottax = 0;
$totamtdue = 0;
$totship = 0;
while($row = mysql_fetch_array($result))
{
$totcharges = $totcharges + $row['charges'];
$tottax = $tottax + $row['tax'];
$totamtdue = $totamtdue + $row['amtdue'];
$totship = $totship + $row['shipamt'];
@penders: it might be a better idea to put those inside the while/if, so it doesn't maintain the value of the last iteration: