www.webdeveloper.com
Results 1 to 2 of 2

Thread: need help w/code

  1. #1
    Join Date
    Apr 2013
    Posts
    74

    need help w/code

    Hello, would someone look at my code and advise how to change. The amt
    payable minus the amt paid drops the cents above ".00". Below is example
    of the problem and below that the pertinent code.
    date days amt
    recur? acct# creditor purpose due paid late payable paid due
    Y 8538 Purina dog food 2013-01-13 0000-00-00 0 72.99 0.00 72.00
    ------------------------------------------------------------------
    PHP Code:
    $totdue $totdue $row['amtdue'];
    $totpaid $totpaid $row['paidamt'];
    $totowed $totdue $totpaid;
    $amtdue str_replace(',''.'$row['amtdue']);
    $paidamt str_replace(',''.'$row['paidamt']);
    $due $row['amtdue'] - $row['paidamt'];
    $due str_replace('.'','$due);

    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>'number_format($due2'.'''), '</td>';
       }
     echo 
    "<tr>";
    echo 
    "<td>Gtotals</td>";
    echo 
    "<td colspan=6></td>";
    echo 
    "<td align=right>" sprintf("%.2f",$totdue) .
    "</td>";
    echo 
    "<td align=right>" sprintf("%.2f",$totpaid) .
    "</td>";
    echo 
    "<td align=right>" sprintf("%.2f",$totowed) .
    "</td>";
    echo 
    "</tr>";
    echo 
    "</table>";
    mysql_close();
    ?> 
    </body></html>

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    731
    You seem to be cleaning the query results data and formatting them as currency but then you don't display the cleaned values, just the $row ones. Why did you create vars $amtdue and $paidamt if you are not displaying them?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles