Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/07/2012, 11:22
ruben_chirinos_1985
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Modificar varios campos de tabla con un solo clickz

Hola de nuevo disculpa pero ya rregle los errores q apareceian ya q no tenia las variables declaradas de nombre, apellido y email, ahora no sale ningun error, pero el problema sigue en q no hace ningun registro de los datos cambio los datos en algunos campos y cuando doy enviar no sale nada aqui estan los codigos como estan ahora.

Código PHP:
Ver original
  1. <?php
  2. $host = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $db = "bdpractica";
  6. $tabla = "test";
  7.  
  8.  
  9. mysql_connect ("$host", "$username", "$password") or die ("No se puede conectar");
  10. mysql_select_db ("$db") or die ("No se puede seleccionar BD");
  11.  
  12. $sql = "SELECT * FROM $tabla";
  13. $resultado=mysql_query($sql);
  14. $count=mysql_num_rows($resultado);
  15. ?>
  16.  
  17. <table width="500" border="1" cellpadding="0">
  18. <form name="form1" method="post" action="modificar11.php">
  19. <tr>
  20. <td align="center"><strong>Id</strong></td>
  21. <td align="center"><strong>Nombre</strong></td>
  22. <td align="center"><strong>Apellido</strong></td>
  23. <td align="center"><strong>Email</strong></td>
  24. <?php
  25. while ($fila=mysql_fetch_array($resultado)) {
  26. ?>
  27. </tr>
  28. <tr>
  29. <td align="center">
  30. <?php $Id[]=$fila['Id'];?>
  31. <?php echo $fila['Id'];?></td>
  32. <td align="center">
  33. <input type="text" name="Nombre" id="Nombre" value="<?php echo $fila['Nombre'];?>"></td>
  34. <td align="center">
  35. <input type="text" name="Apellido" id="Apellido" value="<?php echo $fila['Apellido'];?>"></td>
  36. <td align="center"><input type="text" name="Email" id="Email" value="<?php echo $fila['Email'];?>" /></td>
  37. <?Php
  38. }
  39. ?>
  40. </tr>
  41. <tr>
  42. <td colspan="4" align="center"><input type="submit" name="Enviar" value="Enviar"/>
  43. <?php
  44. $Enviar=$_POST['Enviar'];
  45. $Nombre=$_POST['Nombre'];
  46. $Apellido=$_POST['Apellido'];
  47. $Email=$_POST['Email'];
  48. if($Enviar){
  49. for($i=0;$i<$count;$i++){
  50. $sql1="UPDATE $tabla SET Nombre='$Nombre[$i]', Apellido='$Apellido[$i]',Email='$Email[$i]' WHERE Id=$'Id[$i]'";
  51. $result1=mysql_query($sql1);
  52. }
  53. }
  54. if($result1>0) {
  55. header("Location:modificar11.php");
  56. }
  57. ?> </tr>
  58. </table>