我正试着用十字标志发出警报。不幸的是,十字标志无效。我在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">×</a>You have successfully posted
</div>
';
exit;
}
答案 0 :(得分:1)
将此更改为
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You have successfully posted
此
<a href="#" class="close" data-dismiss="alert" aria-label="close">×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">×You have successfully posted</a>
</div>
<?php
}
else
{
?>
<div class="alert alert-error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×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;
}
}