Log in

View Full Version : help adding 10% to a quote



cow_manuver
07-13-2006, 03:48 AM
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!

cow_manuver
07-14-2006, 01:22 AM
I figured it out, i needed a switch statement, you can delete this post.

NXArmada
07-14-2006, 11:48 AM
Post how you fixed the problem for others to see.

Twey
07-14-2006, 03:07 PM
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 ==.
// 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);