Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/02/2009, 11:08
Avatar de jenusys
jenusys
 
Fecha de Ingreso: diciembre-2008
Ubicación: Ahí mismo.
Mensajes: 216
Antigüedad: 15 años, 4 meses
Puntos: 11
Respuesta: modificar registros de base de datos con php

OK, voy a trabajar para vos pero te voy a condicionar: Si te funciona lo que te voy a poner me tendrás que poner buen KARMA. JAJAJAJAJAJAJAJAJA.

Te voy a poner todo en un solo archivo, (para que no uses más el libro) solo tendrás que copiar y pegar éste código y espero que sea un ¡ LISTO !

El archivo se llamará ejemplo.php

No te pongo lo de la imagen porque no me quedó claro si es una imagen real que luego quieras que los usuarios suban o si es simplemente un código de imagen.

Espero te sirva:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf8">
<title>UN EJEMPLO</title>
</head>

<?php

//Nos conectamos a la base de datos
$bd_host = "localhost";
$bd_usuario = "pecesama";
$bd_password = "pruebas";
$bd_base = "basecurso";
$conexion = mysql_connect($bd_host, $bd_usuario, $bd_password);
mysql_select_db($bd_base, $conexion);

//Convertimos los datos del formulario a cadenas.
$nombre = $_POST['nombre'];
$nombredos = $_POST['nombreact'];
$dire = $_POST['dire'];
$tele = $_POST['tel'];
$ecorreo = $_POST['email'];

$resultados=mysql_query("SELECT * FROM tablacurso WHERE nombre LIKE '%{$nombre}%'", $conexion);
$actual=mysql_query("UPDATE tablacurso SET
nombre='$nombredos',
direccion='$dire',
email='$ecorreo',
telefono='$tele'
WHERE nombre='$nombredos'", $conexion);


//Mostramos el encabezado de los resultados dentro de un formulario que actualizará datos
echo"<form action=ejemplo.php method =post><table border=1 cellspacing=1 cellpadding=1>

<tr>
<td><b>NOMBRE</b></td>
<td><b>DIRECCION</b></td>
<td><b>TELEFONO</b></td>
<td><b>E-MAIL</b></td>
</tr>";

//Creamos el bucle para los resultados
while($row=mysql_fetch_array($resultados)){

echo"
<tr>
<td><input type=text name=nombreact size=20 maxlength=30 value=$row[nombre]></td>
<td><input type=text name=dire size=20 maxlength=30 value=$row[direccion]></td>
<td><input type=text name=tel size=20 maxlength=30 value=$row[telefono]></td>
<td><input type=text name=email size=20 maxlength=30 value=$row[email]></td>
<td><input type=submit name=boton value=ACTUALIZAR></td>
</tr>";

}

echo"</table></form>";

//Cerramos la conexión con MySQL
mysql_close($conexion);
?>

<body>

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

</body>
</html>

Última edición por jenusys; 28/02/2009 a las 12:37