dongqing5575 2018-12-19 01:23
浏览 43
已采纳

CodeIgniter中的错误之前的div css样式加载

I am facing a problem which in my code the error div loads earlier before it shows the error . could someone please help me to fix that

this is my view file

<div class="alert alert-danger mg-b-0" role="alert">
     <?php echo form_error('index'); ?>
     <?php
    if(isset($error)){
        echo 'Your Index number is not registered with our system[enter image description here][1]' . 
        '<br />'.'<a href="http://www.website.com/page.html">Click here to Register</a>'. 
        '<br />';
    }else{
        '<br />';
    }
    ?>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>           
     </div>

here is the screenshot of this
enter image description here

  • 写回答

1条回答 默认 最新

  • dousong1992 2018-12-19 01:35
    关注

    you already printed the alert before the check so if there is no $error it will already show an empty alert, you have to check first then echo your whole divs inside:

    <?php if (isset($error)): ?>
        <div class="alert alert-danger" role="alert">
            <?php echo $error ?> <!-- or write whatever you want -->
        </div>
    <?php endif ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号