Hello good afternoon again in the forum and I have the following question.
I have this code that loads everything in the database into a table, the problem is when deleting by ID ...
Thanks in advance.
<form name="frmInsertarFecha" action="" method="POST">
<table style="width:100%" class="table table-bordered table-responsive">
<tr>
<th>Id</th>
<th>Fecha Inicio</th>
<th>Fecha Termino</th>
<th>Estado</th>
<th>Accion</th>
<th>Accion</th>
</tr>
<?php
$consulta = "SELECT * FROM R_FECHA";
$ejecutar = sqlsrv_query($con, $consulta);
$i = 0;
while ($fila = sqlsrv_fetch_array($ejecutar)) {
$id = $fila['R_FECHA_ID'];
$fechaIni = $fila['R_FECHA_INICIO'];
$fechaTer = $fila['R_FECHA_TERMINO'];
$estado = $fila['R_FECHA_ACTIVO'];
$i++;
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $fechaIni; ?></td>
<td><?php echo $fechaTer; ?></td>
<td><?php echo $estado; ?></td>
<td><input type="button" id="btnEstado" name="btnEstado" value="Modificar Estado"></td>
<td><input type="button" id="btnBorrar" name="btnBorrar" value="Borrar"></td>
<!-- <td><input type="date" name="fInicio" id="fInicio"></td>
<td><input type="date" name="fTermino" id="fTermino"></td>
</td>--> <?php
if (isset($_GET['btnBorrar'])) {
$borrar_id = $_GET['btnBorrar'];
$borrar = "DELETE FROM R_FECHA WHERE R_FECHA_ID = '$borrar_id'";
$ejecutar = sqlsrv_query($con, $borrar);
if ($ejecutar) {
echo "<script>alert('Ha sido Borrado')</script>";
}
}
?>
</tr>