😕
So here is my problem. I have a script the is getting data from a database and I need to take the amount of an invoice total and then subtract the discount plus the amount paid. This result should be zero. It should look like so:
$IAMT = $row['invoice_amount']; // 244.52
$DAMT = $row['discount_amount_taken']; // 12.23
$PAMT = $row['amount_paid']; // 232.29
$TOTAL = $IAMT - ($PAMT + $DAMT); // Should be 0
When I try to see if the result is == 0 I get a false statement. If I echo the $TOTAL I get 2.84217094304E-014😕
Here is this part of the code.
$query2 = "select * from ecom_invoices where supplier_number='".$_GET['supplier']."' order by invoice_date DESC";
$result2 = mysql_db_query($db,$query2,$connection) or die (mysql_error());
while ($row = mysql_fetch_assoc($result2))
{
$IAMT = $row['invoice_amount'];
$DAMT = $row['discount_amount_taken'];
$PAMT = $row['amount_paid'];
$TOTAL = $IAMT - ($PAMT + $DAMT);
if ($i == 0)
{
$class = 'content4';
$i = 1;
}
else if ($i == 1)
{
$class = 'content';
$i = 0;
}
echo "<tr valign='bottom'><td class='".$class."'><font size='-1'>".$row['invoice_number']."</font></td><td class='".$class."'><font size='-1'>".formatDate($row['invoice_date'])."</font></td><td class='".$class."'><font size='-1'>".$row['invoice_amount']."</font></td><td class='".$class."'><font size='-1'>".$row['terms']."</font></td><td class='".$class."'><font size='-1'>".formatDate($row['creation_date'])."</font></td><td class='".$class."'><font size='-1'>";
if ($row['po_number'] != "")
{
echo "<a href='view_po.php?id=".$row['invoice_id']."&vid=".$supplier."' onClick=\"return popup(this, 'notes')\">YES</a>";
}
else
{
echo " ";
}
echo "</font></td><td class='".$class."'><font size='-1'>".$row['discount_amount_taken']."</font></td><td class='".$class."'><font size='-1'>".$row['payment_currency']."</font></td>";
if ( $TOTAL != 0)
{
//echo "<td class='".$class."'><font size='-1' color='red'>".$row['amount_paid']."</font></td><td class='".$class."'><font size='-1'>";
echo "<td class='".$class."'><font size='-1' color='red'>".$TOTAL."</font></td><td class='".$class."'><font size='-1'>";
}
else
{
echo "<td class='".$class."'><font size='-1'>".$row['amount_paid']."</font></td><td class='".$class."'><font size='-1'>";
}
if ($row['payment_method'] == 'CHECK')
{
echo "<a href='chk_lookup.php?id=".$row['invoice_id']."' onClick=\"return popup(this, 'notes')\">CHECK</a></font></td></tr>";
}
else
{
echo $row['payment_method']."</font></td></tr>";
}
}