PHP - problemas para actualizar y borrar registros php

 
Vista:

problemas para actualizar y borrar registros php

Publicado por zule (1 intervención) el 19/10/2005 22:07:45
Oigan acabo de empezar con esto del php tengo instalado el phptriad y no puedo ni actualizar ni borrar registros, pero si puedo ingresarlos a la base de datos ahi les envio el codigo que utilize para ver si me ayudan y me corrigen algun error.

el de actualizacion son tres archivos:
"consulta.php"

<html>
<head>
<title>Ejemplo de PHP</title>
</head>
<body>
<h1>Ejemplo de Modificar</h1>

<form action="busca.php">

Nombre:
<input type="text" NAME="nombre" SIZE="20" MAXLENGTH="30">
<input type="submit" NAME="accion" VALUE="BUSCAR">
</form>
</body>
</html>

"modifica.php"

<?php
include("conec.php");
$link=conectar();
$sq = "UPDATE estudiante SET codigo='$codigo',
nombre='$nombre', apellido='$apellido' WHERE nombre='$nombre'";
mysql_query($sq,$link);

$result=mysql_query("select *from estudiante",$link);
?>
<table border=1 cellspacing=1 cellpadding=1>
<tr>
<td> Codigo</td>
<td> Nombre </td>
<td> Apellido </td>
</tr>

<?php

while ($row = mysql_fetch_array($result)) {
printf("<tr><td> %s</td><td> %s </td><td> %s </td></tr>",
$row['codigo'], $row['nombre'], $row['apellido']);
}

mysql_free_result($result);

?>
</table>

"busac.php"

<html>
<body>
<?php
include("conec.php");
$link=conectar();
$sq = "select *from estudiante where nombre like '% $nombre %'";
$result = mysql_query($sq, $link);
?>


<table border=1 cellspacing=1 cellpadding=1>
<tr>
<td> Codigo</td>
<td> Nombre </td>
<td> Apellido </td>
</tr>

<form name="form1" action="modifica.php">

<?php
while($row = mysql_fetch_array($result))
{
printf("<tr><td> <input type="text" NAME="codigo" SIZE="20" MAXLENGTH="30" VALUE="%s"></td><td> <input type="text" NAME="nombre" SIZE="20" MAXLENGTH="30" VALUE="%s"> </td><td> <input type="text" NAME="apellido" SIZE="20" MAXLENGTH="30" VALUE="%s"> </td></tr>",
$row["codigo"], $row["nombre"], $row["apellido"]);

}
mysql_free_result($result);
?>

</form>

</table>
<input type="submit" NAME="accion" VALUE="Actualizar">

</body>
</html>

archivos de eliminacion:

eliminareg.php

<html>
<head>
</head>
<body>
<?php

include("conec.php");
$link=conectar();
$result=mysql_query("select *from estudiante", $link);
?>

<table border=1 cellspacing=1 cellpadding=1>

<tr>
<td> Codigo</td>
<td> Nombre </td>
<td> Apellido </td>
</tr>

<?php

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["codigo"], $row["nombre"], $row["apellido"], $row["ID"]);

}

mysql_free_result($result);
?>

</table>
</body>
</html>

"borra.php"

<?php

include("conec.php");
$link=conectar();
mysql_query("delete from estudiante where id = '%$id%'", $link);
header("Location: eliminareg.php");
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder