Results 1 to 4 of 4

Thread: help adding 10% to a quote

  1. #1
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy help adding 10% to a quote

    can someone tell me if you spot anything wrong with this code:

    // BEGIN STAIRS/ELEVATORS VARIABLE DEFINITIONS
    if ($OStairs="None") { $o_Stairs=0; }
    else if ($OStairs=1) { $o_Stairs=.1; }
    else if ($OStairs=2) { $o_Stairs=.2; }
    else if ($OStairs=3) { $o_Stairs=.3; }
    else if ($OStairs=4) { $o_Stairs=.4; }
    else if ($OStairs=5) { $o_Stairs=.5; }

    if ($EStairs="None") { $e_Stairs=0; }
    else if ($EStairs=1) { $e_Stairs=.1; }
    else if ($EStairs=2) { $e_Stairs=.2; }
    else if ($EStairs=3) { $e_Stairs=.3; }
    else if ($EStairs=4) { $e_Stairs=.4; }
    else if ($EStairs=5) { $e_Stairs=.5; }

    if ($DStairs="None") { $d_Stairs=0; }
    else if ($DStairs=1) { $d_Stairs=.1; }
    else if ($DStairs=2) { $d_Stairs=.2; }
    else if ($DStairs=3) { $d_Stairs=.3; }
    else if ($DStairs=4) { $d_Stairs=.4; }
    else if ($DStairs=5) { $d_Stairs=.5; }
    // END STAIRS/ELEVATORS VARIABLE DEFINITIONS

    $total += ($total*$o_Stairs) + ($total*$e_Stairs) + ($total*$d_Stairs);

    it is working, but it doesn't add the value, also on the quote page, it defaults to "None" so somehow I guess I am re-assigning the value here. I need it to determine if the input is either None, or 1-5. Then every flight of stairs is 10 percent...

    any help would be greatly appreciated. Thanks!

  2. #2
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I figured it out, i needed a switch statement, you can delete this post.

  3. #3
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Post how you fixed the problem for others to see.
    Ryan
    Sevierville, TN

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    can someone tell me if you spot anything wrong with this code:
    Yes, it's just stupid. You've written ridiculous amounts of code where none is needed, and confused the assignment operator = with the comparison operator ==.
    Code:
    // BEGIN STAIRS/ELEVATORS VARIABLE DEFINITIONS
    
    $o_Stairs = $e_Stairs = $d_Stairs = 0;
    
    if(is_numeric($OStairs) && !is_float($OStairs))
      $o_Stairs = $OStairs / 10;
    
    if(is_numeric($EStairs) && !is_float($EStairs))
      $e_Stairs = $EStairs / 10;
    
    if(is_numeric($EStairs) && !is_float($EStairs))
      $e_Stairs = $EStairs / 10;
    // END STAIRS/ELEVATORS VARIABLE DEFINITIONS
    
    $total += ($total * $o_Stairs) + ($total * $e_Stairs) + ($total * $d_Stairs);
    Last edited by Twey; 07-14-2006 at 03:16 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •