How to make an INSERT of an Array

1

Very Good ...

The query is made to the db, this query only shows the income ids that are in table 1 called (INCOME) and are not in table 2 (BILLING) a chuekbox was placed where the user chooses to which of them will enter the invoice code, enter the invoice code and its status. (The user can take from the list of 1 to 10 ID (Checkbox) when sending it to the DB, with a print_r($_POST); I show by screen what it sends me and it shows me this ---

Array ( [chekbox] => Array ( [0] => 18 [1] => 19 [2] => 12 [3] => 15 [4] => 14 [5] => 13 [6] => 17 [7] => 11 [8] => 16 [9] => 10 ) [num_fac] => 2222 [estado_fac] => 1111 )

What do I want them to be able to help me with? You can enter all of them, whether they are 1 or 10 according to the user's need or criteria, together with the two fields that are invoice code and invoice status. Thank you in advance

<?php

  $strsql = "SELECT cod_ingreso, nombre, apellido, cedula, fecha, formacion, nivel, empresa, num_fac FROM ingresos LEFT OUTER JOIN facturacion ON (cod_ingreso=ingreso_cod) WHERE ingreso_cod is NULL AND fecha ORDER BY fecha ASC LIMIT 10";

  $rs = $mysqli ->query($strsql) or die (mysqli_error());
  $row = mysqli_fetch_assoc($rs);
  $total_rows = mysqli_num_rows($rs);

?>
   </div> 

<hr>
<div style="width:1400px; height:500px; overflow:auto;">
<div class="col-xs-14 col-sm-14 col-md-14 " align="center">
<table cellspacing="0" border="0" width="900" align="justify" class='table table-bordered table-condensed table-hover'>
    <tbody>  
        <theader>
        <tr>
              <th width='100px'>Cod. Ingreso</th>
              <th width='180px'>Nombre</th>
              <th width='180px'>Apellido</th>
              <th width='160px'>Cedula</th>
              <th width='160px'>Fecha</th>
              <th width='130px'>Nivel</th>
              <th width='150px'>Empresa Temporal</th>
              <th width='150px' align="center">Checar</th>

    </tbody>          
<?php if ($total_rows > 0) {
        do {
?>
  <tbody>
    <tr>
      <td width='100px'><?php echo($row['cod_ingreso']); ?></td>
        <td width='180px'><?php echo($row['nombre']); ?></td>
        <td width='180px'><?php echo($row['apellido']); ?></td>
        <td width='160px'><?php echo($row['cedula']); ?></td>
        <td width='160px'><?php echo($row['fecha']); ?></td>       
        <td width='130px'><?php echo($row['nivel']); ?></td>
        <td width='150px'><?php echo($row['empresa']); ?></td>
        <td width='150px' align="center"><input type="checkbox" name="chekbox[]" value="<?php echo $row['cod_ingreso']; ?>"></td>

    </tr>
<?php
        } while ( $row = mysqli_fetch_array($rs) );
        mysqli_free_result($rs);
    } else {
?>
    <tr>
        <td colspan="3">No data found.</td>
    </tr>

<?php } ?>
 </tbody>
</table>
<br>
      <label-success for="nombre"><h4>Codigo de factura</h4></label-success>
      <input type="text" class="form" id="num_fac" name="num_fac">
      <label-success for="nombre"><h4>Estado de la Factura</h4></label-success>
      <input type="text" class="form" id="estado_fac" name="estado_fac">      
   </section> 
   <br>
    <br>
       <div class="acciones">
        <button type="submit" class="btn btn-primary btn-lg btn-block" value="Guardar">Guardar</button>
      </div> 
</form>

This is the table where the data will be entered .. -- Estructura de tabla para la tabla invoicing '

CREATE TABLE 'facturacion' (
  'ingreso_cod' int(100) NOT NULL,
  'cliente' varchar(120) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Factura Generada a:',
  'oingreso' int(50) NOT NULL COMMENT 'Orden de Ingreso',
  'num_fac' int(50) NOT NULL COMMENT 'Numero o Consecutivo de factura',
  'estado_fac' varchar(100) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Estado de la Factura'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci COMMENT='Facturacion';

-

- Table structure for table ingresos

CREATE TABLE 'ingresos' (
  'cod_ingreso' int(100) NOT NULL,
  'cedula' int(100) NOT NULL COMMENT 'Cedula',
  'nombre' varchar(120) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Primer Nombre',
  'nombres' varchar(120) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Segundo Nombre',
  'apellido' varchar(120) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Primer Apellido',
  'apellidos' varchar(120) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Segundo Apeliido',
  'tipo_ced' varchar(30) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Tipo de Cedula',
  'genero' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'pais_nac' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'fecha' date NOT NULL,
  'f_nacimiento' date NOT NULL,
  'tipo_sangre' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'formacion' varchar(120) COLLATE utf8_spanish2_ci NOT NULL,
  'g_sangre' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'nivel' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'nivel_edu' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'sector' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'cargo' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'nivel_l_e' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  's_social' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'o_servicio_ext' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'empresa' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'empresa_temp' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'alergia' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'enfermedades' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'lesiones' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'medicamentos' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'n_contacto' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'tipo_factura' varchar(100) COLLATE utf8_spanish2_ci NOT NULL COMMENT 'Tipo de Factura',
  'tel_contacto' int(100) NOT NULL,
  'c_contacto' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'doc_cumple' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'text_cumple' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'imagen' varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
  'fecha_modifica' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci COMMENT='Table de Ingresos';

' Their respective Indices.

- Indexes in the table facturacion

ALTER TABLE 'facturacion'
  ADD PRIMARY KEY ('num_fac'),
  ADD KEY 'ingreso_cod' ('ingreso_cod');

- Indexes in the table ingresos

ALTER TABLE 'ingresos'
  ADD PRIMARY KEY ('cod_ingreso'),
  ADD UNIQUE KEY 'cod_ingreso' ('cod_ingreso');
    
asked by Rsistemas 24.07.2018 в 19:12
source

1 answer

0

After 2 days trying in many ways and ways I have already achieved it, I share for those who are in the same need of help. This is the file that manages the form that I previously placed.

 $ string)); $ string_final = substr ($ string, 0, -1); $ end_chain.=";"; $ msn = header ("location: /HMC/html/factura/fac_dinamica.php"); if ($ mysqli- > query ($ end_chain)): echo json_encode (array ($ msn = > false)); else: echo json_encode (array ('error' = > true)); endif;  $ mysqli -> close (); ? >     
answered by 26.07.2018 / 18:53
source