Posted by Paul Furman on 03/03/07 06:40
Kimmo Laine wrote:
> Paul Furman kirjoitti:
>
>> First, I'm sure the following code is not using an efficient structure
>> for the nested if then else's but I can't recall the right way:
>>
>
> With the help of our friend "else if" you get a really clean code:
>
> if ($item_qty > 19) {
> $price = ($price * .925);
> $qty_discount = '20 @ 7.5%';
> } else if ($item_qty > 9) {
> $price = ($price * .95);
> $qty_discount = '10 @ 5%';
> } else if ($item_qty > 4) {
> $price = ($price * .975);
> $qty_discount = '5 @ 2.5%';
> }
Thanks, that's better.
I should know this stuff...
[Back to original message]
|