【问题标题】:Div css style load before the error in CodeIgniter在 CodeIgniter 出错之前加载 Div css 样式
【发布时间】:2018-12-19 09:35:58
【问题描述】:

我遇到了一个问题,在我的代码中,错误div 在显示错误之前加载得更早。有人可以帮我解决这个问题吗

这是我的视图文件

<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>

这是这个截图

【问题讨论】:

    标签: php html css codeigniter


    【解决方案1】:

    你已经在检查之前打印了警报,所以如果没有 $error 它已经显示一个空警报,你必须先检查然后在里面回显你的整个 div:

    <?php if (isset($error)): ?>
        <div class="alert alert-danger" role="alert">
            <?php echo $error ?> <!-- or write whatever you want -->
        </div>
    <?php endif ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 2019-07-13
      • 1970-01-01
      相关资源
      最近更新 更多