Cuando le doy al boton o palabra o hypervinculo Borrar (para que me ejecute el codigo del formulario borrar.php) del registro que selecciona me funciona, es decir lo elimina, pero no me sucede lo mismo con el boton o palabra o hypervinculo Editar (formulario editar.php). Este ultimo me deberia llevar al formulario modificar.php en donde me debera traer los datos del registro seleccionado segun el id del registro para que luego me permita reemplazar estos datos por otros y efectuar el update o actualizacion.
En el navegador me asocia el registro seleccionado con el id, o sea cuando sale por ejemplo (localhos/editar.php?id=101010) que al parecer me esta confirmando que la ejecucion del query es correcto, pero me esta traiendo todos los registros de la tabla mas no el que yo selecciono
A continuacion el codigo de los formularios:
datos.php
Código PHP:
Ver original
<table> <tr> <td>Nombre:</td> <td><input type="text" name="nombre" size="15" maxlength="30"></td> <td>Direccion:</td> <td><input type="text" name="direccion" size="15" maxlength="30"></td> <td>Telefono:</td> <td><input type="text" name="telefono" size="15" maxlength="30"></td> <td>Email:</td> <td><input type="text" name="email" size="15" maxlength="30"></td> <td>Imagen:</td> <td><input type="text" name="imagen" size="15" maxlength="30"></td> </tr> </table> <input type="submit" name="accion" value="Aceptar"> </form> <hr> <?php include("conec.php"); $link=Conectarse(); ?> <table border=1 cellspacing=1 cellpadding=1> <tr> <td> Nombre</td> <td> Dirección </td> <td> Telefono </td> <td> Email </td> <td> Imagen </td> <td> <img src="trash-icon.png"> </td> <td> <img src="Edit-icon.png"> </td> </tr> <?php { <td> <input type='text' name='nombre' size='20'maxlength='30' value='%s'></td> <td> <input type='text' name='direccion' size='20' maxlength='30' value='%s'> </td> <td> <input type='text' name='telefono' size='20' maxlength='30' value='%s'> </td> <td> <input type='text' name='email' size='20' maxlength='30' value='%s'> </td> <td> <input type='text' name='imagen' size='20' maxlength='30'value='%s'> </td> <td><a href=\"borra.php?id=%d\">Borra</a></td> <td><a href=\"modifica.php?id=%d\">Editar</a></td> </tr>", $row["nombre"],$row["direccion"],$row["telefono"],$row["email"],$row["imagen"],$row["id"],$row["id"]); } ?> </table> </body> </html>
borrar.php
Código PHP:
Ver original
<?php include("conec.php"); $link=Conectarse(); ?> <SCRIPT> alert('Se han guardado los datos...'); location.href='datos.php'; </SCRIPT> <?
modifica.php
Código PHP:
Ver original
<?php include("conec.php"); $link=Conectarse(); ?> <form id="form1" name="form1" action""> <table> <tr> <td>Nombre:</td> <td><input type="text" name="nombre" size="15" maxlength="30"></td> <td>Direccion:</td> <td><input type="text" name="direccion" size="15" maxlength="30"></td> <td>Telefono:</td> <td><input type="text" name="telefono" size="15" maxlength="30"></td> <td>Email:</td> <td><input type="text" name="email" size="15" maxlength="30"></td> <td>Imagen:</td> <td><input type="text" name="imagen" size="15" maxlength="30"></td> </tr> </table> <input type="submit" name"enviar" value"Modificar"> <table border=1 cellspacing=1 cellpadding=1> <tr> <td> Nombre</td> <td> Dirección </td> <td> Telefono </td> <td> Email </td> <td> Imagen </td> <td> <img src="trash-icon.png"> </td> <td> <img src="Edit-icon.png"> </td> </tr> ?> while($row = mysql_fetch_array($result)) { printf("<tr> <td> <input type='text' name='nombre' size='20'maxlength='30' value='%s'></td> <td> <input type='text' name='direccion' size='20' maxlength='30' value='%s'> </td> <td> <input type='text' name='telefono' size='20' maxlength='30' value='%s'> </td> <td> <input type='text' name='email' size='20' maxlength='30' value='%s'> </td> </tr>", $row["nombre"],$row["direccion"],$row["telefono"],$row["email"]); } ?> <? { query= "update bd set Nombre='$nombre', Direccion='$direccion,' Telefono=$telefono, Email='$email' "; echo 'Actualizacion exitosa!' } ?>