Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/10/2009, 20:13
NoobxD
 
Fecha de Ingreso: octubre-2009
Mensajes: 3
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar DE DOS tablas relacionadas

Código html:
Ver original
  1. <meta http-equiv="content-type" content="text/html; charset=utf8">
  2. <title>UN EJEMPLO</title>
  3. </head>
Código php:
Ver original
  1. <?php
  2.  
  3.  
  4. $conexion = mysql_connect("localhost","root");
  5. mysql_select_db("pecesama", $conexion);
  6.  
  7. //Convertimos los datos del formulario a cadenas.
  8. $nombre = $_POST['nombre'];
  9. $nombredos = $_POST['nombreact'];
  10. $dire = $_POST['dire'];
  11. $tele = $_POST['tel'];
  12. $ecorreo = $_POST['email'];
  13.  
  14. $resultados=mysql_query("SELECT * FROM tablacurso WHERE nombre LIKE '%{$nombre}%'", $conexion);
  15. $actual=mysql_query("UPDATE tablacurso SET
  16. nombre='$nombredos',
  17. direccion='$dire',
  18. email='$ecorreo',
  19. telefono='$tele'
  20. WHERE nombre='$nombredos'", $conexion);
  21.  
  22.  
  23. //Mostramos el encabezado de los resultados dentro de un formulario que actualizará datos
  24. echo"<form action=ejemplo.php method =post><table border=1 cellspacing=1 cellpadding=1>
  25.  
  26. <tr>
  27. <td><b>NOMBRE</b></td>
  28. <td><b>DIRECCION</b></td>
  29. <td><b>TELEFONO</b></td>
  30. <td><b>E-MAIL</b></td>
  31. </tr>";
  32.  
  33. //Creamos el bucle para los resultados
  34. while($row=mysql_fetch_array($resultados)){
  35.  
  36. echo"
  37. <tr>
  38. <td><input type=text name=nombreact size=20 maxlength=30 value=$row[nombre]></td>
  39. <td><input type=text name=dire size=20 maxlength=30 value=$row[direccion]></td>
  40. <td><input type=text name=tel size=20 maxlength=30 value=$row[telefono]></td>
  41. <td><input type=text name=email size=20 maxlength=30 value=$row[email]></td>
  42. <td><input type=submit name=boton value=ACTUALIZAR></td>
  43. </tr>";
  44.  
  45. }
  46.  
  47. echo"</table></form>";
  48.  
  49. //Cerramos la conexión con MySQL
  50. mysql_close($conexion);
  51. ?>

[HIGHLIGHT="html"]
Código html:
Ver original
  1.  
  2. <small>INGRESE SUS DATOS</small><br>
  3. <form action="ejemplo.php" method ="post">
  4. <input type="text" name="nombre" size="20" maxlength="30">
  5. <input type="submit" name="boton" value="ENVIAR">
  6. </form><br>
  7.  
  8. </body>
  9. </html>[HIGHLIGHT="html"]
[/HIGHLIGHT]

Última edición por NoobxD; 20/10/2009 a las 20:25