Need help w/code

Hello,

I get decimals every 3 or 4 lines for “due” w/the following.
all entries in the dabase table are decimal(.00)

$$totdue = $totdue + $row['amtdue'];
$totpaid = $totpaid + $row['paidamt'];
$totowed = $totowed + $row['amtdue'];

$amtdue = str_replace(',', '.', $row['amtdue']);
$paidamt = str_replace(',', '.', $row['paidamt']);
[B]$due[/B] = $amtdue - $paidamt;
// [B]$due[/B] = str_replace('.', ',', $due);

Can this following be done w/str_replace?

$late = $row['dayslate'];
if ($late > 120)
{
$row['dayslate'] = "pastdue";
}

// $row['duedate'] = preg_replace('/^[0:-]*$/', '', $row['duedate']);
// $row['datepaid'] = preg_replace('/^[0:-]*$/', '', $row['datepaid']);
// if(str_replace(array('0','-',':'),' ',$row['dayslate'])=>'120');{$row['dayslate']='past due';}
echo "<tr>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>" . $row['acctno'] . "</td>";
echo "<td>" . $row['bname'] . "</td>";
echo "<td>" . $row['purpose'] . "</td>";
echo "<td>" . $row['duedate'] . "</td>";
echo "<td>" . $row['datepaid'] . "</td>";
echo "<td align=right>" . $row['dayslate'] . "</td>";
echo "<td align=right>" . $row['amtdue'] . "</td>";
echo "<td align=right>" . $row['paidamt'] . "</td>";

echo '<td align=right>'[B].$due.'[/B]</td>';

   }

Without data it is not easy to see the errors.

Try this and replace with suitable data .


<?php 
error_reporting(-1); 
ini_set('display_errors',true);


$row = array
(
    'amtdue'         => 123.45,
    'totdue'         => 123.45,
    'paidamt'     => 123.45,
    'totpaid'        => 123.45,
    'totowed'        => 123.45,
    'dayslate'    => 123.45,
    'status'        => 123.45,
    'acctno'        => 123.45,
    'bname'            => 123.45,
    'purpose'        => 123.45,
    'duedate'        => 123.45,
    'datepaid'    => 123.45,
    );


$totdue  = 0; 
$totpaid = 0; 
$totowed = 0; 
// $$totdue = $totdue + $row['amtdue']; 
$totdue  = $totdue  + $row['amtdue']; 
$totpaid = $totpaid + $row['paidamt']; 
$totowed = $totowed + $row['amtdue']; 


$amtdue  = str_replace(',', '.', $row['amtdue']); 
$paidamt = str_replace(',', '.', $row['paidamt']); 
///// [B]$due[/B] = $amtdue - $paidamt; 
$due     = $amtdue - $paidamt; 
// [B]$due[/B] = str_replace('.', ',', $due);  


$late = $row['dayslate']; 
if ($late > 120) 
{    
$row['dayslate'] = "pastdue"; 
}  


// $row['duedate'] = preg_replace('/^[0:-]*$/', '', $row['duedate']); 
// $row['datepaid'] = preg_replace('/^[0:-]*$/', '', $row['datepaid']); 
// if(str_replace(array('0','-',':'),' ',$row['dayslate'])=>'120');{$row['dayslate']='past due';}  


$header=<<<TMP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  lang="EN" xml:lang="EN">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en"/>
<title>title goes here</title>
<style type='text/css'>
  .tar {text-align:right;}
  table {width:22em; border:solid 1px #0f0}
  table td {padding: 0.42em; border:solid 1px #f00}
</style>
</head>
<body>
TMP;


echo $header;
    echo '<table summary="summary goes here">';
        echo "<tr>"; 
        echo "<td>" . $row['status']         . "</td>"; 
        echo "<td>" . $row['acctno']         . "</td>"; 
        echo "<td>" . $row['bname']         . "</td>"; 
        echo "<td>" . $row['purpose']     . "</td>"; 
        echo "<td>" . $row['duedate']     . "</td>"; 
        echo "<td>" . $row['datepaid']    . "</td>"; 
        echo '<td class="tar">'     . $row['dayslate']     . "</td>"; 
        echo '<td class="tar">'     . $row['amtdue']         . "</td>"; 
        echo '<td class="tar">'     . $row['paidamt']     . "</td>";  
        echo '<td class="tar">[B]'.$due .'[/B]</td>'; 
        //  }  
    echo '</table>';
echo '</body></html>';