Page 1 of 1

print table doesn't align correctly

Posted: Sun Apr 17, 2011 2:02 pm
by ckdoublenecks
this code works correctly except that the print table doesn't display correctly and the totcharges doesn't display the decimals. Can someone look at this and advise?

Code: Select all

<?php
mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database");
$query=" SELECT * FROM oocust WHERE payrec = 'R' AND pd = ' '";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo date("m/d/Y") . "<br />";
echo "<font size=+2><b> Old Orchard Plumbing Invoices 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 colspan=5></th>
<tr>
<th>Inv#</th>
<th>Customer</th>
<th align=left>date</th>
<th>days late</th>
<th align=right>Charges</th>
<th align=right>tax</th>
<th align=right>Owed</th>
<tr>
<TH colspan=11>=======================================================================</TH>
</tr>";
while($row = mysql_fetch_array($result))
{
// $charges=$row['charges'];
// $tax=$row['tax'];
// $amtdue=$row['amtdue'];
$totcharges = $totcharges + $row['charges'];
$tottax = $tottax + $row['tax'];
$totamtdue = $totamtdue + $row['amtdue'];
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['charges'] . "</td>";
echo "<td align=right>" . $row['tax'] . "</td>";
echo "<td align=right>" . $row['amtdue'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<table cellspacing=1 cellpadding=0 border=0>
<tr>
<tr>
<TH colspan=11>=======================================================================</TH>
</tr>";
echo "<tr>";
echo "<td>Totals Due</td>";
echo "<td>.</td>";
echo "<td>.</td>";
echo "<td>.</td>";
echo "<td>.</td>";

echo "<td align=right>$totcharges</td>";
echo "<td align=right>$tottax</td>";
echo "<td align=right>$totamtdue</td>";
echo "</tr>";
echo "</table>";
mysql_close();
?> 

Re: print table doesn't align correctly

Posted: Mon Apr 18, 2011 12:26 pm
by incubi
Hi,

If $totcharges is not showing the decimals but the $row['charges'] has them then try using number_format() to get what you want.

As for the alignment the only thing I see is your HTML is not complete be sure you have the <HTML> <BODY> and <HEAD> tags.



Lee

Re: print table doesn't align correctly

Posted: Mon Apr 18, 2011 1:03 pm
by califdon
We can help you better if you describe your problem. What do you mean by "table doesn't display correctly"???

Re: print table doesn't align correctly

Posted: Mon Apr 18, 2011 1:58 pm
by ckdoublenecks
thanks, fellows for the input. I'm printing all records (which match my selector) into one table, then printing totals into another. I know this will never align. What I need is to know how to print the totals so that they will align.

Re: print table doesn't align correctly

Posted: Mon Apr 18, 2011 4:35 pm
by incubi
Still not sure I enough info to help. If I could see a sample of what you want it to look like it would help.
However, you could try encapsulating your other tables in a table so the Totals Due falls inline.