如何将复选框值插入数据库两列
How to insert Checkbox value to database two columns
我需要一个复选框数据发送到数据库。
table姓名"status"
列名"inline"
列名"offline"
选中该复选框后,应将 "IN" 插入 "IN"
列
当复选框未选中时,它应该将 "OUT" 插入 "OUT"
列
谢谢!
查看
<div class="form-group">
<div class="col-md-10">
<input type="checkbox" checked data-toggle="toggle" data-on="IN" data-off="OUT">
</div>
</div>
控制器
public function updateStatu(){
$this->load->model('Status_Board_Model');
$statuid = $this->input->post('statuid');
$data = array(
'online' => $this->input->post('online'),
'offline' => $this->input->post('offline'),
'comment' => $this->input->post('comment'),
);
$this->Status_Board_Model->updateStatu($statuid, $data);
echo json_encode(数组("status" => TRUE));
}
试试这个
{
$check=$this->input->post('check');
if($check=="on")
{
$checkval="IN";
Store value here inline column
}
else{
$checkval="OUT";
Store value here offline column
}
}
我需要一个复选框数据发送到数据库。
table姓名"status"
列名"inline"
列名"offline"
选中该复选框后,应将 "IN" 插入 "IN"
列当复选框未选中时,它应该将 "OUT" 插入 "OUT"
列谢谢!
查看
<div class="form-group">
<div class="col-md-10">
<input type="checkbox" checked data-toggle="toggle" data-on="IN" data-off="OUT">
</div>
</div>
控制器
public function updateStatu(){
$this->load->model('Status_Board_Model');
$statuid = $this->input->post('statuid');
$data = array(
'online' => $this->input->post('online'),
'offline' => $this->input->post('offline'),
'comment' => $this->input->post('comment'),
);
$this->Status_Board_Model->updateStatu($statuid, $data);
echo json_encode(数组("status" => TRUE)); }
试试这个
{
$check=$this->input->post('check');
if($check=="on")
{
$checkval="IN";
Store value here inline column
}
else{
$checkval="OUT";
Store value here offline column
}
}