if语句中的if语句 [英] If statement within an if statement
问题描述
我是一个完整的新手用PHP脚本,但我很想学习。
我需要一些帮助,请。
任何人都可以为我排序这个代码,以便它正常工作和
调整前端所选数量的价格。
__________________________________________________ _____________
if(article_get_field(''type'')=='''Croclight Candle''){
article_set_field(''item_number'',''CRC'');
article_set_field(''price'',6.99);
}
elseif(article_get_field(''type'')=='''Spray'' ){
article_set_field(''item_number'',''CRS'');
article_set_field(''size'',''50ml''); br />
article_set_field(''price'',6.99);
}
elseif(article_get_field(''size'')=='''15ml' '){
article_set_field(''item_number'', 'CRS'');
article_set_field(''type'',''Spray'');
article_set_field(''price'',2.99);
}
elseif(article_get_field(''type'')==''滚动''){
article_set_field(''item_number' ',''CRO'');
article_set_field(''size'',''50ml'');
article_set_field(''price'',6.99) ;
}
__________________________________________________ ______________
提前致谢
Mark
I am a complete novice with php scrip but I am wiling to learn.
I am in need of some help, please.
Can anyone sort this code out for me so that it works correctly and
adjusts the price for the quantity selected on the front end.
__________________________________________________ _____________
if(article_get_field(''type'')== ''Croclight Candle''){
article_set_field(''item_number'', ''CRC'');
article_set_field(''price'', 6.99);
}
elseif(article_get_field(''type'')== ''Spray'') {
article_set_field(''item_number'', ''CRS'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
}
elseif(article_get_field(''size'')== ''15ml'') {
article_set_field(''item_number'', ''CRS'');
article_set_field(''type'', ''Spray'');
article_set_field(''price'', 2.99);
}
elseif(article_get_field(''type'')== ''Roll-on'') {
article_set_field(''item_number'', ''CRO'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
}
__________________________________________________ ______________
Thanks in advance
Mark
推荐答案
" Mark" <毫安************ @ ntlworld.com>写在
新闻:11 ********************** @ g49g2000cwa.googlegr psps.com:
"Mark" <ma************@ntlworld.com> wrote in
news:11**********************@g49g2000cwa.googlegr oups.com:
我是一个完整的新手用PHP脚本,但我很想学习。
我需要一些帮助,请。
任何人都可以为我排序这个代码这样它可以正常工作并调整前端所选数量的价格。
__________________________________________________ _____________
if(article_get_field(''type'')=='' Croclight Candle''){
article_set_field(''item_number'',''CRC'');
article_set_field(''price'',6.99);
}
elseif (article_get_field(''type'')==''Spray''){
article_set_field(''item_number'',''CRS'');
article_set_field(''size'',' '50ml'');
article_set_field(''price'',6.99);
}
elseif(article_get_field(''size'')=='''15ml''){<清楚le_set_field(''item_number'',''CRS'');
article_set_field(''type'',''Spray'');
article_set_field(''price'',2.99);
}
elseif(article_get_field(''type'')==''滚动''){
article_set_field(''item_number'',''CRO'');
article_set_field(''size'',''50ml'');
article_set_field(''price'',6.99);
}
I am a complete novice with php scrip but I am wiling to learn.
I am in need of some help, please.
Can anyone sort this code out for me so that it works correctly and
adjusts the price for the quantity selected on the front end.
__________________________________________________ _____________
if(article_get_field(''type'')== ''Croclight Candle''){
article_set_field(''item_number'', ''CRC'');
article_set_field(''price'', 6.99);
}
elseif(article_get_field(''type'')== ''Spray'') {
article_set_field(''item_number'', ''CRS'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
}
elseif(article_get_field(''size'')== ''15ml'') {
article_set_field(''item_number'', ''CRS'');
article_set_field(''type'', ''Spray'');
article_set_field(''price'', 2.99);
}
elseif(article_get_field(''type'')== ''Roll-on'') {
article_set_field(''item_number'', ''CRO'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
}
第一个建议:如果可能的话,尽量避免使用elseif。请改用开关()
语句。 <见http://www.php.net/switch>
开关(article_get_field(''type'')){
case'' Croclight Candle'':
article_set_field(''item_number'',''CRC'');
article_set_field(''price'',6.99);
休息;
case''Spray'':
article_set_field(''item_number'','''CRS'');
article_set_field(''size'',''50ml'');
article_set_field(''price'',6.99);
break;
case''Roll-on'':
article_set_field(''item_number'',''CRO'');
article_set_field(''size '','''50ml'');
article_set_field(''price'',6.99);
休息;
}
if(article_get_field(''size'')=='''15ml''){
article_set_field(''item_number'',''CRS'' );
article_set_field(''typ e'',''Spray'');
article_set_field(''price'',2.99);
}
另外,在发布代码时,尝试使用缩进,以便确定不同的
代码块。
Ken
First suggestion: Avoid elseif''s if at all possible. Use the switch()
statement instead. <see http://www.php.net/switch>
switch (article_get_field(''type'')) {
case ''Croclight Candle'':
article_set_field(''item_number'', ''CRC'');
article_set_field(''price'', 6.99);
break;
case ''Spray'':
article_set_field(''item_number'', ''CRS'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
break;
case ''Roll-on'':
article_set_field(''item_number'', ''CRO'');
article_set_field(''size'', ''50ml'');
article_set_field(''price'', 6.99);
break;
}
if(article_get_field(''size'') == ''15ml'') {
article_set_field(''item_number'', ''CRS'');
article_set_field(''type'', ''Spray'');
article_set_field(''price'', 2.99);
}
Also, when posting code, try to use indentation so that the different
code blocks can be determined.
Ken
< comp.lang.php,Ken Robinson, se *** *******@rbnsn.com >
< 1124745948.eba2d174dc98eac000e32e39523bcf98@teran ews>
< Mon,2005年8月22日21格林威治标准时间25:48>
<comp.lang.php , Ken Robinson , se**********@rbnsn.com>
<1124745948.eba2d174dc98eac000e32e39523bcf98@teran ews>
<Mon, 22 Aug 2005 21:25:48 GMT>
第一个建议:如果可能的话,尽量避免使用elseif。请改用switch()
语句。 <参见http://www.php.net/switch>
开关(article_get_field(''type'')){snip code}
另外,发帖时代码,尝试使用缩进,以便可以确定不同的代码块。
First suggestion: Avoid elseif''s if at all possible. Use the switch()
statement instead. <see http://www.php.net/switch>
switch (article_get_field(''type'')) {snip code}
Also, when posting code, try to use indentation so that the different
code blocks can be determined.
这看起来很不错的代码,我一直都有意思要了解
开关()多年,但我反其道而且大多数时候我认为
缩进是一种诅咒。
if(
That looked a nice bit of code and i''ve been meaning to learn about
switch() for ages , But i''m the opposite and most of the time I regard
indents as a curse .
if (
poo<>
poo<>
这篇关于if语句中的if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!