Send more than one record to the same record in the database

1

I have a dependents registry with the form sending correctly to the DB. I came across the problem that I did not realize that the worker can have more than one dependent, I would like to know how I can add more than one dependent to the employee, I create more fields if I have other dependents but how will it be and / or will it be sent to my BD and record together with the employee?

This is my code to add dependent;

<tr>
<td>Tipo de Dependente:</td>
  <td><select name="tpDep" id="tpDep">
    <option></option>
    <option value="01">Cônjuge;</option>
    <option value="02">Companheiro(a) com o(a) qual tenha filho ou viva há mais de 5 (cinco) anos ou possua Declaração de União Estável;</option>
    <option value="03">Filho(a) ou enteado(a);</option>
    <option value="04">Filho(a) ou enteado(a), universitário(a) ou cursando escola técnica de 2º grau;</option>
    <option value="06">Irmão(ã), neto(a) ou bisneto(a) sem arrimo dos pais, do(a) qual detenha a guarda judicial;</option>
    <option value="07">Irmão(ã), neto(a) ou bisneto(a) sem arrimo dos pais, universitário(a) ou cursando escola técnica de 2° grau, do(a) qual detenha a guarda judicial;</option>
    <option value="09">Pais, avós e bisavós;</option>
    <option value="10">Menor pobre do qual detenha a guarda judicial;</option>
    <option value="11">A pessoa absolutamente incapaz, da qual seja tutor ou curador;</option>
    <option value="12">Ex-cônjuge;</option>
    <option value="99">Agregado/Outros;</option>
</tr>

<tr>
  <td width="69">Nome:</td>
  <td width="546"><input name="nmDep" type="text" id="nmDep" size="70" maxlength="70" />
    <span class="style1"></span></td>
</tr>

<tr>
  <td>Data de Nascimento:</td>
  <td><input name="dtNascto" type="text" placeholder="DD/MM/AAAA" id="dtNascto" size="10" maxlength="10" />
         <small><small><i><span class="style1"></span></td></small></small></i>
</tr>

<tr>
  <td width="69">CPF:</td>
  <td width="546"><input name="cpfDep" type="text" id="cpfDep" size="15" maxlength="11" />
    <span class="style1"></span></td>
</tr>

<tr>
  <td>Deduz IRRF?</td>
  <td><input name="depIRRF" type="radio" value="S" />
    Sim
    <input name="depIRRF" type="radio" value="N" />
    Não <span class="style1"></span> </td>
<tr>    
<td>Salário Família?</td>
  <td><input name="depSF" type="radio" value="S" />
    Sim
    <input name="depSF" type="radio" value="N" />
    Não <span class="style1"></span> </td>  
</tr>   
<tr>    
<td>Defic. Fisica ou Mental?</td>
  <td><input name="incTrab" type="radio" value="S" />
    Sim
    <input name="incTrab" type="radio" value="N" />
    Não <span class="style1"></span> </td>  
</tr>
    
asked by anonymous 13.03.2018 / 19:25

1 answer

2

The ideal is to have a table for the worker and a table separda only for the dependents. Then you use% worker% as the foreign key in the dependency table.

Already in programming. You allow the addition of a number of dependents in a fixed (3 for example) or dynamic form, with a "Add Dependent" button that through javascript adds fields in the employee's own form. Or a specific separate route only for the dependent register after the employee's registration.

In any case, you will have to make 2 querys of id , one for the worker and another for each dependent with the foreign worker registered as the worker.

    
13.03.2018 / 19:39