You are here: Re: 2 dumb questions « PHP Programming Language « IT news, forums, messages
Re: 2 dumb questions

Posted by Kimmo Laine on 03/03/07 05:19

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%';
}

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация