如何将Checkbox值插入数据库的两列

时间:2019-07-19 19:01:55

标签: javascript codeigniter checkbox toggle

我需要一个复选框数据才能发送到数据库。

表名“状态”

列名“内联”

列名“离线”

选中此复选框时,应在“ IN”列中插入“ IN”

取消选中该复选框时,应在“ OUT”列中插入“ OUT”

谢谢!  enter image description here

视图

                        <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(array(“ status” => TRUE));     }

1 个答案:

答案 0 :(得分:0)

尝试


Traceback (most recent call last):
  File "C:\Users\StackOverflow\Desktop\temp.py", line 15, in <module>
    group = Friends('frank', 'greg', 'evil_string')
  File "C:\Users\StackOverflow\Desktop\temp.py", line 10, in __init__
    raise TypeError('Why are you giving me strings!')
TypeError: Why are you giving me strings!