vendredi 19 juillet 2019

How to insert Checkbox value to database two columns

I need one checkbox data to send to the database.

table name "status"

the column name "inline"

the column name "offline"

when the checkbox is checked it should insert "IN" into column "IN"

when the checkbox is unchecked it should insert "OUT" into column "OUT"

Thanks! enter image description here

view

                        <div class="form-group">                        
                         <div class="col-md-10">                       
            <input type="checkbox" checked data-toggle="toggle" data-on="IN" data-off="OUT">             
                    </div>
                    </div>

controller

         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)); }




Aucun commentaire:

Enregistrer un commentaire