Foro de programación en PHP
programacion php
| Autor: nathaly Publicado: 21-4-2008 10:58 AM |
|
|
necesito un documento que me permita borrar registros el que tengo es el siguiente pero no lo elimina: eliminar.php <html> <head> <title>Consulta Reporte</title> </head> <body> <?php include('connexion.php'); $result=mysql_query("select * from eventos"); echo" <BR><BR><table width=\"550\" height=\"50\" borde bordercolor=\"#003399\" align=\"center\" border=\"2\"> <tr> <td width=\"100\" height=\"90\" rowspan=\"2\" bgcolor=\"#003399\"><div align=\"center\"><img src=\"imagenes/unefa.png\" width=\"70\" height=\"80\" align=\"middle\" /></div></td> <td width=\"300\" height=\"30\"> <p align=\"center\" class=\"Estilo3\">AUDITORIO ALÍ PRIMERA</p></TD> <td width=\"100\" height=\"90\" rowspan=\"2\" bgcolor=\"#003399\"><div align=\"center\"><img src=\"imagenes/pasillo3.jpg\" width=\"90\" height=\"80\" align=\"middle\" /></div></td> </tr> <tr> <td bgcolor=\"#0066FF\"><div align=\"center\" class=\"Estilo1\">"; setlocale (LC_TIME,"spanish"); echo"<div align=right><strong>"; echo strftime("%d de %B del %Y"); echo"</strong></div>"; echo" </div> </td> </tr> </table> <table background=\"imagenes/Auditorio1.jpg\" width=\"550\" height=\"50\" borde=\"0\" bordercolor=\"#003399\" align=\"center\"> <tr> <td colspan=\"2\"><p> <table width=\"550\" height=\"100\" border=\"0\" align=\"center\"> <br><tr> <td> <p align=\"center\"><strong><font size=5 color=\"0033cc\">Modificar Evento</font></strong></p> <center><TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4> <TR> <TD bgcolor=\"#003399\"><font color=\"#FFFFFF\"><strong> <B>codigo evento</B></strong></font></TD> <TD bgcolor=\"#003399\"><font color=\"#FFFFFF\"><strong> <B>Fecha</B></strong></font></TD> <TD bgcolor=\"#003399\"><font color=\"#FFFFFF\"><strong> <B>Nombre</B></strong></font> </TD> <TD bgcolor=\"#003399\"><font color=\"#FFFFFF\"><strong> <B>Borrar</B></strong></font> </TD> </TR>"; while($row = mysql_fetch_array($result)) { printf("<tr><td> %s</td><td> %s </td><td> %s </td><td><a href=\"borra.php?id=%d\">Borra</a></td></tr>", $row["id_evento">,$row["fecha">,$row["nombre_evento">,$row["ID_Prueba">); } mysql_free_result($result); echo"</TABLE></center> <br> <table width=\"530\" border=\"0\" align=\"center\"> <tr> <td> <center><input name=\"boton\" type=\"button\" onClick=\"javascript:history.go(-1)\" value=\"Cancelar\" /> </td> </tr><br> </table></center> </form> <tr> <td colspan=\"2\" bgcolor=\"#003399\"> </td> </tr> <tr> <td> </table> </table>"; ?> </body> </html> borrar.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head> <body> <?php include('connexion.php'); // $link=Conectarse(); $id_evento=$_GET['id_evento']; mysql_query("delete from eventos where where ID_Prueba = $id_evento"); header("Location:eliminar.php"); ?> </body> </html> por favor ayudenme |
|
| Autor: Natxo Publicado: 21-4-2008 02:49 PM |
|
| No encuentro el tag del form, pero aún así cambia esto: <a href=\"borra.php?id=%d\">Borra</a></td></tr>... Por: <a href="borrar.php?id_evento=$row["id_evento">"> Borra </a></td></tr>... Creo que van con \" y quedaría: <a href=\"borrar.php?id_evento=".$row["id_evento">."\"> Borra </a></td></tr>... (es que sin la ayuda de los colorines del código del dreamweaver me pierdo un poco). Lo primero es que según tu código es "borrar.php" y no "borra.php" Lo segundo es que el parámetro que recoges por $_GET en borrar.php se llama id_evento, mientras que el que mandas por el href es id, y se tiene que llamar igual que el que recoges. Empieza por esto y si no funciona luego seguimos mirando. No te líes con tanto %s y esas cosas, es más fácil que todo eso. No hace falta ese código típico del C++. |
|
| Autor: nathaly Publicado: 21-4-2008 03:46 PM |
|
| while($row = mysql_fetch_array($result)) { printf("<tr><td> %s</td><td> %s </td><td> %s </td><td><a href=\"borra.php?=id_evento\">Borra</a></td></tr>", $row["id_evento">,$row["fecha">,$row["nombre_evento">); } mysql_free_result($result); |
|
| Autor: nathal Publicado: 22-4-2008 02:03 PM |
|
| ya no me aparece el error ahora no me elimina estoy colocando esto y nada no me elimina el registro <?php include('connexion.php'); // $link=Conectarse(); $id_evento=$_GET['id_evento']; mysql_query("delete from eventos where id_evento = '$id_evento'"); ?> <SCRIPT LANGUAGE="javascript"> alert("Evento Borrado!!!"); location.href = "eliminar.php?"; </SCRIPT> <?php //CIERRA CONEXION DE LA BASE DE DATOS mysql_close(); ?> no me elimina nada de la base de datos |
|
