Hello good day My problem is that I have a table of type of vehicles and plates and I need you to update by means of a button, it only works with the first data shown by the while, but it does not change it with the others
MI JAVASCRIPT
function enviarplacas () {
var tipo_vehiculo;
var placa;
datosactualizados2 = {
tipo_vehiculo : $ ('.vehiculo').val(),
placa : $ ('.placa').val(),
idinsp
};
$.post('php/formularioactualiza/editar_placas.php', datosactualizados2, function(rtaactualiza2) {
console.log(rtaactualiza2)
if (rtaactualiza2 == 2){
alert('se ha actualizado correctamente las placas');
return;
}
if (rtaactualiza2 == 1){
alert('No se pudo procesar las placas');
return;
}
});
console.log(datosactualizados2)
}
MY PHP
<?php
if (isset($_POST['inspeccionID']) ) {
$inspeccion_id = $_POST['inspeccionID'];
include("conexion.php");
$result = mysqli_query($mysqli," SELECT * FROM vehiculo_inspeccion WHERE id_inspeccion = '$inspeccion_id' ");
if (!empty($result)) {
if (mysqli_num_rows($result) > 0) {
while ($fila = mysqli_fetch_array($result)){
$fila_array['tipo_vehiculo']= $fila['tipo_vehiculo'];
$fila_array['placa']= $fila['placa'];
$fila_array['id_veh_ins']= $fila['id_veh_ins'];
echo "
<tr>
<td colspan='3'><input type='text' class='form-control vehiculo' disabled='true' id='tipveh".$fila_array['id_veh_ins']."' value='".$fila_array['tipo_vehiculo']."'></td>
<td colspan='3'><input type='text' class='form-control placa' disabled='true' id='plc".$fila_array['id_veh_ins']."' value='".$fila_array['placa']."'></td>
<td colspan='3'><input type='button' class='btn btn-success' id='".$fila_array['id_veh_ins']."' onclick='activarplaca(this)' value='Editar'></button></td>
</tr>
";
}
} else {
echo "
<tr>
<td colspan='6'> No se encontraron placas en la inspeccion seleccionada.
</td>
</tr>
";
}
} else {
echo "
<tr>
<td colspan='6'> No se encontraron placas en la inspeccion seleccionada. </td>
</tr>
";
}
} else {
echo "Error";
}
?>
MY HTML
<div>
<center>
<table width="55%" rules="all" border="1" align="center" class="table table-bordered table-hover">
<thead bgcolor="#30c151">
<th colspan="3">Tipo vehiculo</th>
<th colspan="3">Placa</th>
<th colspan="3">EDITAR</th>
</thead>
<tbody class="datosplaca">
</tbody>
</table>
<center>
<button type="button" id="guardardatos" class="btn btn-info" onclick="enviarplacas()"> ACTUALIZAR PLACAS</button>
</center>
</div>