Lisawynn

04-27-2006, 06:25 PM

Hi. There is a problem with the following if statement and I can't figure out where I went wrong. It seems that $cost is being tested the first 2 times but if $cost is over $100, the value of $discount is a negative number. Can someone please take a look and tell me where my error is? Thanks very much!!

<? if ($cost < 50)

{

$discount=0;

}

else if ($cost >= 50 || $cost < 100)

{

$rate=100 - $cost;

$discount=$rate *.10;

}

else if ($cost >= 100 || $cost < 150)

{

$rate=150 - $cost;

$discount=$rate *.08;

}

else if ($cost >= 150 || $cost < 200)

{

$rate=200 - $cost;

$discount=$rate *.06;

}

else

{

print "I don't know what was selected";

}

print $discount;

?>

Thanks!!!

<? if ($cost < 50)

{

$discount=0;

}

else if ($cost >= 50 || $cost < 100)

{

$rate=100 - $cost;

$discount=$rate *.10;

}

else if ($cost >= 100 || $cost < 150)

{

$rate=150 - $cost;

$discount=$rate *.08;

}

else if ($cost >= 150 || $cost < 200)

{

$rate=200 - $cost;

$discount=$rate *.06;

}

else

{

print "I don't know what was selected";

}

print $discount;

?>

Thanks!!!