print table doesn't align correctly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ckdoublenecks
Forum Newbie
Posts: 21
Joined: Mon Jan 24, 2011 6:47 pm

print table doesn't align correctly

Post 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();
?> 
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Re: print table doesn't align correctly

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: print table doesn't align correctly

Post by califdon »

We can help you better if you describe your problem. What do you mean by "table doesn't display correctly"???
ckdoublenecks
Forum Newbie
Posts: 21
Joined: Mon Jan 24, 2011 6:47 pm

Re: print table doesn't align correctly

Post 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.
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Re: print table doesn't align correctly

Post 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.
Post Reply