Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/09/2004, 17:36
angel_toledo
 
Fecha de Ingreso: agosto-2004
Mensajes: 58
Antigüedad: 19 años, 8 meses
Puntos: 0
Modificando Registros

Stoy trabajando en un script , pero reguiere q tenga una seccion donde se pueden modificar registros d la base d datos, me baje el siguient codigo y ya no me manda error, pero no aparece nada cuando despues d entrar a elejir elijo lo q quiero editar (no se s me di a entender), el codigo d modificacion consta d 3 archivos, el primero si sta bien el problema es el segundo y como no puedo poner en marcha el segundo no se si el tercero sta bien

Aqui sta el codigo d cada uno:
elejir.php
Código PHP:
<?php

$conexion 
mysql_connect("localhost""root""");
if (! 
$conexion)
{
echo 
"<h2 align='center'>ERROR: Imposible establecer conexión con el servidor</h2>";
exit;
}
mysql_select_db("test"$conexion);

$result mysql_query("SELECT * FROM usuarios"$conexion);
echo 
"<center>Elige un registro de la lista para Modificar:<br></center><br><br>";
echo 
"<center><table border = '1' bgcolor='#ffffff'> \n";
echo 
"<form method='post' action='edita.php'>";
while (
$row mysql_fetch_row($result))
{
echo 
"<tr> \n";
echo 
"<td> <font color='#000000' size=3><input type=submit name='id' value=$row[0]> </font> </td> \n";
echo 
"<td> <font color='#000000' size=3> $row[1] </font> </td> \n";
echo 
"<td> <font color='#000000' size=3> $row[2] </font> </td> \n";
echo 
"<td> <font color='#000000' size=3> $row[3] </font></td> \n";
echo 
"<td> <font color='#000000' size=3> $row[4] </font></td> \n";
echo 
"<td> <font color='#000000' size=3> $row[5] </font></td> \n";
echo 
"</tr> \n";
}
?>
edita.php (donde sta el problema)
Código PHP:
<?php

$conexion 
mysql_connect("localhost","root","") or die("No se pudo realizar la conexion con el servidor"); 

mysql_select_db("test") or die (mysql_error()); 

$busqueda="SELECT * FROM usuarios WHERE id ='$numero'";
$resultado_b=mysql_query($busqueda); 
if(
$row=mysql_fetch_row($resultado_b)) 

echo 
"
<form name=formulario method=post action=modifica_registro.php>
<input type=hidden name='numero' value='$numero'>

<table border='0' width='769' cellpadding='0' cellspacing='1' >
<input type='HIDDEN' name='id' value='$row[0]' size='10' maxlength='10'>

<tr>
<td width='92' bgcolor='#CCCCCC' height='21'><b>Socios</b></td>
<td width='568' height='21'></td>
</tr>
<tr>
<td width='92' height='28'>&nbsp;Nombre&nbsp;</td>
<td width='568' height='28'>&nbsp; <input type=text value='$row[1]' size='75' maxlength='25' name='nombre'></td>
</tr>
<tr>
<td width='92' height='34'>&nbsp;Apellidos&nbsp;</td>
<td width='568' height='34'> &nbsp; <input type='text' name='apellidos' value='$row[2]' size='75' maxlength='50'></td>
</tr>
<tr>
<td width='92' height='34'>&nbsp;Edad&nbsp;</td>
<td width='568' height='34'>&nbsp; <input type='text' name='edad' value='$row[3]' size='6' maxlength='25'></td>
</tr>
<tr>
<td width='92' height='34'>
Telefono</td>
<td width='568' height='34'>&nbsp; <input type='text' name='telefono' size='5' maxlength='11' value='$row[4]'></td>
</tr>
<tr>
<td width='92' height='2'>&nbsp;Población</td>
<td width='568' height='2'>&nbsp;&nbsp; <input type='text' name='poblacion' size='23' maxlength='35' value='$row[5]'>
C.P. <input type='text' name='codpostal' size='5' maxlength='11' value='$row[6]'>&nbsp;
Provincia <input type='text' name='provincia' size='13' maxlength='11' value='$row[7]'>&nbsp;&nbsp;
<input type=submit value='Enviar &gt;&gt;'>
</td>
</tr>
</table>
</form>
"

}
?>
modifica_registro.php (no he llegado aqui )
Código PHP:
<?php

$conexion 
mysql_connect("localhost""root","");
mysql_select_db("test",$conexion);

$consulta "UPDATE usuarios SET nombre='$nombre', apellidos='$apellidos', edad='$edad' , telefono='$telefono', poblacion='$poblacion', provincia='$provincia' , codpostal='$codpostal' WHERE id='$numero'";

$resultado mysql_query($consulta);
if (
$resultado)
{
echo 
"<font color=ff0000 size=4> El registro ha sido Modificado </font>\n";

}
else 

echo 
"<p>¡No se ha podido modificar.!</p>\n"

exit;
}
mysql_close($conexion);
?>