I have a table of requests and what I want to do is a UPDATE
that when I mark the checkbox
of several of them, I update the database that all the selected ones are en route.
Launches me an error:
Notice: Undefined variable: row in C: \ xampp \ htdocs \ Login18 \ Login \ view \ checkruta.php on line 15 Data Inserted Successfully!
<form action="checkruta.php" method="post" >
<table class="my-table">
<thead>
<tr>
<th>Folio</th>
<th>Nombre</th>
<th>Fecha Solicitud</th>
<th>Solicitud</th>
<th>Estado</th>
<th>Fecha reporte</th>
<th>Seleccionar Ruta</th>
<th><input type="submit" name="guardar" value="guardar"/></th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($query))
{
$id=$row[0];
?>
<tr>
<td><?php echo $row[0];?></td>
<td><?php echo $row[1];?></td>
<td><?php echo $row[6];?></td>
<td><?php echo $row[7];?></td>
<td><?php echo $row[8];?></td>
<td><?php echo $row[10];?></td>
<?php echo "<td><input type='checkbox' id='cbox1' name='rutas[]' value='<?php echo $row[0];?>'> <br></td>";?>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="table-pagination pull-right">
<?php echo paginate($reload, $page, $total_pages, $adjacents);?>
</div>
</form>
<?php
}
else
{
?>
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4>Aviso!!!</h4> No hay datos para mostrar
</div>
<?php
\Codigo de insercion
<?php
extract($_POST);
$server = "localhost";
$usuario = "root";
$contraseña = "";
$bd = "bdpagina";
$conexion = mysqli_connect($server, $usuario, $contraseña, $bd)
or die("error en la conexion");
if( !empty( $_POST[ 'rutas' ] ) )
{
foreach( $_POST[ 'rutas' ] as $ruta )
{
$conn = mysqli_connect("localhost", "root", "", "bdpagina");
$query="UPDATE contribuyente SET ruta = '$ruta' WHERE contribuyente. id = '$row[0]'";
$result = mysqli_query($conn, $query);
echo "Data Inserted Successfully!";
echo $ruta;
}
}
?>