SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    seattle
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    grandtotal problem

    i'm having a problem getting the grandtotal to print correctly.
    if it's under 1,000, let say $958, then it will display the right amount, but if it's over $1,000 it will display the grandtotal as $1.00.
    this is my code.

    if($jid == '2') {
    $GrandTotal = number_format($TotalCost + $labortotal + $trash - $amount),2);
    }
    else {
    $GrandTotal = number_format($TotalCost + $labortotal + $inspection + $trash - $amount),2);

    i echoed out the $TotalCost, $labortotal, $inspection, $trash, & $amount and all the amounts are correct.

  2. #2
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    365
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure if this is your problem or just a typo but on both line the brackets dont match

    PHP Code:

    if($jid == '2') {
       
    $GrandTotal number_format($TotalCost $labortotal $trash $amount,2);

    else 
    {
       
    $GrandTotal number_format($TotalCost $labortotal $inspection $trash $amount ,2);


  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    i echoed out the $TotalCost, $labortotal, $inspection, $trash, & $amount and all the amounts are correct.
    Post a sample of those values and lets have a look.

    Edit: Instead of echoing them, use var_dump() on each one and show us the output.

  4. #4
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i noted something wrong your code. i think you need two brackets

    if($jid == '2') {
    $GrandTotal = number_format(($TotalCost + $labortotal + $trash - $amount),2);
    }
    else {
    $GrandTotal = number_format(($TotalCost + $labortotal + $inspection + $trash - $amount),2);
    Power of Knowledge

  5. #5
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    seattle
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks i figured it out.


Bookmarks

Posting Permissions

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