2016-04-25 85 views
-6

我很困惑。这么简单的事情。它只是不会“elseif”不能让elseif工作

我需要的是这样的:<?php if ($pscorelabel >= 21) : ?>做某事这样做:<?php if ($pscorelabel >= 42) : ?>做别的。

我附上了代码片段。请,我是一个小白菜,需要你的帮助。任何帮助将不胜感激。

<?php if ($showscore == '1') : ?> 
<div class="ipt_fsqm_up_number"> 
<h6> 
<?php $ui->print_icon_by_class('quill', false); ?> 
<?php printf(__('%2$s%% Average %1$s', 'ipt_fsqm'), $scorelabel, number_format_i18n(($avg_score * 100), 0)); ?> 
</h6> 

<?php endif; ?> 

<?php if ($pscorelabel >= 21) : ?> <div class="ipt_fsqm_up_meta"> 
<h6><?php $ui->print_icon_by_class('quill', false); ?> 
<?php printf(__('%2$s Total CPD Points %1$s', 'ipt_fsqm'), $finallabel, number_format_i18n(($pscorelabel * 1), 0)); ?> 
</h6> 
<?php elseif ($pscorelabel >= 42) : ?>                        
<div class="ipt_fsqm_up_meta"> 
<h6><?php $ui->print_icon_by_class('quill', false); ?> 
<?php printf(__('%2$s Total CPD Points %1$s', 'ipt_fsqm'), $finallabel, number_format_i18n($finallabel = 6, 0)); ?> 
</h6> 

<?php endif; ?> 
+2

请正确格式化你的代码。 – Wavemaster

+0

首先摆脱结合标记和逻辑;) –

+0

使用非becaketed如果/然后语句与HTML中断可能导致问题,您的代码首先需要一些清理。下面的答案是正确的,你的42和21是交换的,因为第二个真实的条件会在第一个真实的,第二个永远不会达到。如果你想要两个eval单独忽略其他如果为正常如果。 – Wobbles

回答

1

更新你的代码,把> 42以上的条件,然后&> 21条件

<?php 
    if ($pscorelabel >= 42) { ?>                        
    <div class="ipt_fsqm_up_meta"> 
    <h6><?php $ui->print_icon_by_class('quill', false); ?><?php printf(__('%2$s Total CPD Points %1$s', 'ipt_fsqm'), $finallabel, number_format_i18n($finallabel = 6, 0)); ?></h6> 

    <?php 

    } elseif ($pscorelabel >= 21) { ?> <div class="ipt_fsqm_up_meta"> 
    <h6><?php $ui->print_icon_by_class('quill', false); ?><?php printf(__('%2$s Total CPD Points %1$s', 'ipt_fsqm'), $finallabel, number_format_i18n(($pscorelabel * 1), 0)); ?></h6> 


    <?php } ?> 
+0

我已经尝试过,但仍然没有快乐。任何其他想法? – user3003638

+0

您的情况下$ pscorelabel的价值是多少? –

+0

它目前为100 – user3003638