Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/08/2009, 08:21
cate324
 
Fecha de Ingreso: agosto-2009
Mensajes: 11
Antigüedad: 14 años, 8 meses
Puntos: 0
actualizar registro db mysql

hola a todos... podria ayudarme con este codigo? necesito actualizar los registros de una base de datos(mysql) haciendo la busqueda con el nombre... pero no se en que me estoy equivocando... alguien puede orientarme??? muchas gracias de antemano por su ayuda....
aqui les dejo el codigo para que lo vea...

<?php


$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "123456";
$bd_base = "ccsrc";
$conexion = mysql_connect($bd_host, $bd_usuario, $bd_password);
mysql_select_db($bd_base, $conexion);


$nombre=$_POST['nombre'];
$nombresdos = $_POST['nombresact'];
$apellidos = $_POST['apellidos'];
$fn = $_POST['nacimiento'];
$c=$_POST['civil'];
$direccion=$_POST['direccion'];
$telr = $_POST['telr'];
$telm = $_POST['telm'];
$ocupacion=$_POST['ocupacion'];
$ingreso=$_POST['ingresos'];
$observaciones=$_POST['observaciones'];

$resultados=mysql_query("SELECT * FROM habitantes WHERE nombre LIKE '%{$nombre}%'", $conexion);
$actual=mysql_query("UPDATE habitantes SET

nombres='$nombresdos',
apellidos='$apellidos',
fechan='$fn',
civil='$c',
direccion='$direccion',
telfor='$telr',
telm='$telm',
ocupacion='$ocupacion',
ingresos='$ingresos',
observaciones='$observaciones',
WHERE nombre='$nombresdos'", $conexion);

echo"<form action=actualiza.php method =post><table border=1 cellspacing=1 cellpadding=1>

<tr>

<td><b>nombres</b></td>
<td><b>apellidos</b></td>
<td><b>fecha de nacimiento</b></td>
<td><b>estado civil</b></td>
<td><b>direccion</b></td>
<td><b>telefono residencial</b></td>
<td><b>telefono movil</b></td>
<td><b>ocupacion</b></td>
<td><b>ingresos</b></td>
<td><b>observaciones</b></td>
</tr>";

while($row=mysql_fetch_array($resultados)){
echo"
<tr>

<td><input type=text name=nombresact size=20 maxlength=30 value=$row[nombres]></td>
<td><input type=text name=apellidos size=20 maxlength=30 value=$row[apellidos]></td>
<td><input type=text name=nacimiento size=20 maxlength=30 value=$row[fechan]></td>
<td><input type=text name=civil size=20 maxlength=30 value=$row[civil]></td>
<td><input type=text name=direccion size=20 maxlength=30 value=$row[direccion]></td>
<td><input type=text name=telr size=20 maxlength=30 value=$row[telefor]></td>
<td><input type=text name=telm size=20 maxlength=30 value=$row[telem]></td>
<td><input type=text name=ocupacion size=20 maxlength=30 value=$row[ocupacion]></td>
<td><input type=text name=ingresos size=20 maxlength=30 value=$row[ingresos]></td>
<td><input type=text name=observaciones size=20 maxlength=30 value=$row[observaciones]></td>
<td><input type=submit name=boton value=ACTUALIZAR></td>
</tr>";

}

echo"</table></form>";
mysql_close($conexion);
?>

<body>

<small>INGRESE SUS DATOS</small><br>
<form action="actualiza.php" method ="post">
<input type="text" name="nombre" size="20" maxlength="30">
<input type="submit" name="boton" value="ENVIAR">
</form><br>

</body>
</html>