Ver Mensaje Individual
  #10 (permalink)  
Antiguo 22/09/2010, 08:15
ommm
 
Fecha de Ingreso: septiembre-2010
Mensajes: 92
Antigüedad: 16 años
Puntos: 1
Pregunta Respuesta: Eliminar un registro php de la fila

Cita:
Iniciado por AdrianSeg Ver Mensaje
Como estas montando la tabla en la que salen las fechas reservadas? usas un id autoincremental para hacer las busquedas? Pon el codigo que construye la tabla y te diremos como arreglarlo...el problema es que no estas pasando valor alguno por el id.
Mi tabla es algo asi:


Código PHP:
 <link href="stylever.css" rel="stylesheet" type="text/css"> 

<?php
$link 
= mysql_connect("localhost", "usuario", "contraseña");
mysql_select_db("pruebasa_coches", $link);
 

$result = mysql_query("SELECT the_date, salida, destino FROM bookings where correo='" . $_POST['correo'] . "' ORDER BY the_date ASC LIMIT 10", $link);
if (
$row = mysql_fetch_array($result)){
echo 
"<table class='tabla'> \n";
echo 
"<tr> \n";
echo 
"<td class='tit'><b>Fecha</b></td> \n";
echo 
"<td class='tit'><b>Salida</b></td> \n";
echo 
"<td class='tit'><b>Destino</b></td> \n";
echo 
"<td class='tit'><b>Acción</b></td> \n";

echo 
"</tr> \n";
while (
$row = mysql_fetch_row($result)){
echo 
"<tr> \n";
echo 
"<td class='borde'>$row[0]</td> \n";
echo 
"<td class='borde'>$row[1]</td> \n";
echo 
"<td class='borde'>$row[2]</td> \n";
echo 
"<td class='borde'><b><a href='borrar.php?id=$id'>Borrar reserva</a></b></td> \n";

echo 
"</tr> \n";

}
}

?>
y en el archivo borrar.php lo que ha puesto antes él.


Código PHP:

$link 
= mysql_connect("localhost", "usuario", "contraseña");
mysql_select_db("pruebasa_coches", $link);
  
      
$id = $_GET['id'];
 
       

      
$sql = "DELETE FROM bookings WHERE id=$id";
  
      
mysql_query($sql) or die (mysql_error()); 

GRACIAS:D:D