Ver Mensaje Individual
  #12 (permalink)  
Antiguo 18/07/2015, 11:24
diegoferrg
 
Fecha de Ingreso: mayo-2010
Mensajes: 30
Antigüedad: 14 años
Puntos: 0
Respuesta: ¿Cómo actualizar registros de bases de datos MYSQL con php?

Ya lo prové y no actualiza nada.

Mira yo tengo este otro código, que es muy parecido y que actualiza, un solo registro el id_item que ya tengo previamente en el codigo selecionado, este codigo hace la actualización bien, pero el problema es que necesito que sea de cada uno de los registros que selecione con el boton.

A continuación el código que solo actualiza un registro:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>

<body>
<p class="mio">VER REGISTRO DE GASTOS DE LOS FRAILES ESTUDIANTES
<form action="" method="post">
<span class="mio">
<input type="submit" value="Ver registro de gastos de todos los frailes" name="ver_lista_gastos" >
</span>
</form>
<table style="width: 100%">
<?php
$conexion=mysqli_connect("localhost","root","","si ndicatura") or die("Problemas con la conexión");
$consulta=mysqli_query($conexion,"SELECT `id_item`, `item_pedido`, `fecha_peticion`, `costo`, `estado_aprobacion`, `nombre_quien_aprueba`, `fecha_aprobacion` FROM `registros`;") or
die("Problemas en el select:".mysqli_error($conexion));
echo "<table width='847' border='1' cellspacing='2' cellpadding='3'> \n
<tr>
<th width='195' bgcolor='#999999' scope='col'>SOLICITUD</th>
<th width='87' bgcolor='#999999' scope='col'>FECHA DE SOLICITUD</th>
<th width='72' bgcolor='#999999' scope='col'>COSTO</th>
<th width='111' bgcolor='#999999' scope='col'>ESTADO DE LA SOLICITUD</th>
<th width='115' bgcolor='#999999' scope='col'>NOMBRE DE QUIEN APRUEBA</th>
<th width='107' bgcolor='#999999' scope='col'>FECHA DE APROBACION</th>
</tr>
";

?>
<form action="" method="post">
<?php
while($registro = mysqli_fetch_array($consulta))
{
?>

<td><input type="text" value="<?php echo $registro['item_pedido']?>" name="nombres[]"></td>
<td><input type="text" value="<?php echo $registro['fecha_peticion']?>" name="departamento[]" class="letrapequeña" ></td>
<td><input type="text" value="<?php echo $registro['costo']?>" name="idempleado[]"></td>
<td><input type="text" value="<?php echo $registro['estado_aprobacion']?>" name="nombres[]"></td>
<td><input type="text" value="<?php echo $registro['nombre_quien_aprueba']?>" name="departamento[]" class="letrapequeña" ></td>
<td><input type="text" value="<?php echo $registro['fecha_aprobacion']?>" name="idempleado[]"></td>
<td>
<input type="submit" value="APROBAR gastos" name="aprobar" ></td>

</tr>

<?php
}

if(isset($_POST['aprobar'])){
$id_item2=$registro['id_item'];

mysqli_query($conexion,"UPDATE `sindicatura`.`registros` SET `estado_aprobacion` = 'APROBADO' WHERE `registros`.`id_item` = 1;");
}

?>
</form>

</table>
</body>
</html>

Yo a este codigo no le encuentro diferencia con el anterior que no funciona, la diferencia es con el anterior que busco hacer la actualización de forma dinamica para cada registro.