javascript – update records of dynamic add and delete rows using php?

exception or error:

I want to update the record of dynamic add and delete rows. These rows add data into database with new line and id. The Primary Key is incremental, the other user ID is static, i want to fetch all the rows data and show it into the input fields respectively. whenever i try to fetch data from database, it just fetch first row data with the ID, and not the other rows data with the same ID. Need your kind attention towards this query please help me for the correct code

$Sql3 = "SELECT * FROM tbl_professional_certification WHERE apli_reg_no = '$id';";
$result1 = mysqli_query($conn, $Sql3);
$row5 = mysqli_fetch_array($result1, MYSQLI_ASSOC);
$count5 = mysqli_num_rows($result1);

for($i = 0; $i< $count5; $i++)
{

   echo $certificate_title[$i] = $row5['certificate_title'];
    $certificate_file[$i] = $row5['certificate_file'];
}

$(document).ready(function() {
  var i = 1;
  $("#Add_CERT").click(function() {
    $('#CERT' + i).html("<td>" + (i + 1) + "</td><td><input name='CERTName[" + i + "]' type='text' placeholder='e.g. PMP, MCPS, CCNA, CCNP etc.' class='form-control input-md'  /> </td><td><input type='file' name='CERT_File[" + i + "]'  class='form-control input-md'></td>");

    $('#Tab_CERT').append('<tr id="CERT' + (i + 1) + '"></tr>');
    i++;
  });
  $("#Delete_CERT").click(function() {
    if (i > 1) {
      $("#CERT" + (i - 1)).html('');
      i--;
    }
  });

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-md-12">
  <p>
    <b>Have You Acquired Any Professional Certification?</b> <span style="color: red">*</span>
  </p>


  <select class="form-control show-tick form-group form-float" name="ProfessionalCertificate" id="ProfessionalCertificate" required>
    <option selected disabled>Select Option</option>
    <option id="Yes1" value="Yes">Yes</option>
    <option id="No1" value="No">No</option>
  </select>
</div>


<!-- CERTIFICATE TABLE START -->
<div class="col-md-12 Yes box5">
  <p>
    <b>Please Upload</b>
  </p>
  <div class="form-group form-float">
    <table class="table table-bordered table-hover" id="Tab_CERT">
      <thead>
        <tr>
          <th>#</th>
          <th>Certification Name</th>
          <th>Attach Certificate</th>
        </tr>
      </thead>

      <tbody>
        <tr id='CERT0'>
          <td>1</td>
          <td>
            <input type="text" name='CERTName[0]' placeholder='e.g. PMP, MCPS, CCNA, CCNP etc.' class="form-control" />
          </td>

          <td>
            <input type="file" name="CERT_File[0]" class="form-control" />
          </td>
        </tr>

        <tr id='CERT1'></tr>
      </tbody>
    </table>
  </div>
  <a id="Add_CERT" class="btn btn-default pull-left">Add Row</a><a id='Delete_CERT' class="pull-right btn btn-default">Delete Row</a>
</div>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *