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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器