Insert or update values of a checkbox - PHP

0

Well I want to insert the values true or false according to the checkbox marked to a BD which is the following:

    CREATE TABLE 'campos_req' (
  'id_req' int(11) NOT NULL AUTO_INCREMENT,
  'nombre_campo_req' varchar(120) NOT NULL,
  'check_req' tinyint(1) NOT NULL,
  PRIMARY KEY ('id_req')
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;

My form is as follows:

    <form name="form_req" id="form_req" method="POST" ACTION="#">
  <table cellpadding="0" cellspacing="0" border="0" class="display">
    <tbody>              
      <tr align="center"> 
            <td width="20%"><p><label><input id="check_ani" type="checkbox" name="check_ani" >ANI</label></p></td>
            <td width="20%"><p><label><input id="check_id" type="checkbox" name="check_id" >IDENTIFICADOR</label></p></td>
            <td width="20%"><p><label><input id="check_cliente" type="checkbox" name="check_cliente" checked>NOMBRE CLIENTE</label></p></td>
            <td width="20%"><p><label><input id="check_tipo_cliente" type="checkbox" name="check_tipo_cliente" >TIPO CLIENTE</label></p></td>
            <td width="20%"><p><label><input id="check_cliente_empresa" type="checkbox" name="check_cliente_empresa" >EMPRESA</label></p></td>
        </tr>                
      <tr>
            <td width="20%"><p><label><input id="check_observacion" type="checkbox" name="check_observacion" >OBSERVACIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_sucursal" type="checkbox" name="check_sucursal" checked>SUCURSAL</label></p></td>
            <td width="20%"><p><label><input id="check_direccion" type="checkbox" name="check_direccion" >DIRECCIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_fono1" type="checkbox" name="check_fono1" >FONO 1 SUC</label></p></td>
            <td width="20%"><p><label><input id="check_fono2" type="checkbox" name="check_fono2" >FONO 2 SUC</label></p></td>
        </tr>

      <tr>
            <td width="20%"><p><label><input id="check_contacto" type="checkbox" name="check_contacto" checked>CONTACTO</label></p></td>
            <td width="20%"><p><label><input id="check_fono_contacto" type="checkbox" name="check_fono_contacto" checked>FONO CONTACTO</label></p></td>
            <td width="20%"><p><label><input id="check_email_contacto" type="checkbox" name="check_email_contacto" checked>EMAIL CONTACTO</label></p></td>
            <td width="20%"><p><label><input id="check_fecha_creacion" type="checkbox" name="check_fecha_creacion" >F. CREACIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_num_ticket" type="checkbox" name="check_num_ticket" >N° TICKET</label></p></td>
        </tr>   

      <tr>
            <td width="20%"><p><label><input id="check_fecha_cierre" type="checkbox" name="check_fecha_cierre" >F. CIERRE</label></p></td>
            <td width="20%"><p><label><input id="check_creador" type="checkbox" name="check_creador" >CREADOR</label></p></td>
            <td width="20%"><p><label><input id="check_duracion" type="checkbox" name="check_duracion" >DURACIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_estado_ven" type="checkbox" name="check_estado_ven" >E. VENCIMIENTO</label></p></td>
            <td width="20%"><p><label><input id="check_tipo_trabajo" type="checkbox" name="check_tipo_trabajo" >TIPO TRABAJO</label></p></td>
        </tr>

      <tr>
            <td width="20%"><p><label><input id="check_estado" type="checkbox" name="check_estado" >ESTADO</label></p></td>
            <td width="20%"><p><label><input id="check_tipo_turno" type="checkbox" name="check_tipo_turno" >TIPO DE TURNO</label></p></td>
            <td width="20%"><p><label><input id="check_tipo_atencion" type="checkbox" name="check_tipo_atencion" >TIPO ATENCIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_ticket_tecnico" type="checkbox" name="check_ticket_tecnico" >ASIGNADO A</label></p></td>
            <td width="20%"><p><label><input id="check_categoria" type="checkbox" name="check_categoria" checked>CATEGORIA</label></p></td>
        </tr>

      <tr>

            <td width="20%"><p><label><input id="check_requerimiento" type="checkbox" name="check_requerimiento" checked>REQUERIMIENTO</label></p></td>
            <td width="20%"><p><label><input id="check_descripcion" type="checkbox" name="check_descripcion" >DESCRIPCIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_severidad" type="checkbox" name="check_severidad" >SEVERIDAD</label></p></td>
            <td width="20%"><p><label><input id="check_fecha_limite_sol" type="checkbox" name="check_fecha_limite_sol" >FECHA LIMITE DE SOLUCIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_hora" type="checkbox" name="check_hora" >HORA</label></p></td>
        </tr>

      <tr>
            <td width="20%"><p><label><input id="check_descripcion_solucion" type="checkbox" name="check_descripcion_solucion" value="" >DESCRIPCIÓN DE SOLUCIÓN</label></p></td>
            <td width="20%"><p><label><input id="check_comentario" type="checkbox" name="check_comentario" value="" >COMENTARIO</label></p></td>
      </tr>
    </tbody>

</table>
    <!--Botones aplicar y cancelar -->
<table width="100%" border="0" cellpadding="1" cellspacing="1">
                <tbody><tr>
                    <td width="30%"></td>
                    <td width="20%"><center><input type="submit" name="guardar" id="guardar" value="Guardar" class="btn-table" onclick="enviar_form();" ></center></td> 
                    <td width="20%"><center><input type="reset" name="limpiar" id="limpiar" value="Limpiar" class="btn-table"></center></td>
                    <td width="30%"></td>
                </tr>
 </tbody></table>

How can I know which ones were marked before? and How can I take the values of the form and perform an 'update' to the current DB? PD: In the bd I have recorded data with 0 and 1.

    
asked by Carlos Escobar 15.05.2017 в 17:47
source

0 answers