Codeigniter Bootstrap警报无法正常工作

时间:2015-10-13 03:50:49

标签: php jquery html twitter-bootstrap codeigniter

我正试着用十字标志发出警报。不幸的是,十字标志无效。我在bootstrap.js之前包含了jquery。这是我的模特。在此先感谢

public function create(){
    $data = array('name'=>  $this->input->post('name'));
        $this->db->insert('dbname', $data);
        echo'
          <div class="alert alert-success">
            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You have successfully posted
         </div>
       ';
        exit;
}

1 个答案:

答案 0 :(得分:1)

将此更改为

<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You have successfully posted

<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;You have successfully posted</a>

以及 使用Model将数据写入数据库 。使用以下

在控制器中

public function create(){

    $this->load->model('Model_name');
    $result = $this->Model_name->insert_data();

    if($result == 1)
    {
        ?>
          <div class="alert alert-success">
            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;You have successfully posted</a>
         </div>
         <?php
    }
    else
    {
        ?>
          <div class="alert alert-error">
            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;Failed to poste</a>
         </div>
         <?php
    }


}

在模型中

public function insert_data()
{
    $data = array(
    'name'=>  $this->input->post('name')
    );

    if(!$this->db->insert('dbname', $data))
    {
        return $log = 0;
    }
    else
    {
        return $log = 1;
    }
}