Ver Mensaje Individual
  #7 (permalink)  
Antiguo 21/11/2013, 15:52
ghiovani_999
 
Fecha de Ingreso: noviembre-2013
Mensajes: 11
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: Modificación de multiples registros en un

YA LO SOLUCIONE POR DEDUCCIONES PROPIAS..... POR FIN..
[LE DEJO EL CÓDIGO COMPLETO]
Código PHP:
Ver original
  1. <?php
  2. # FileName="Connection_php_mysql.htm"
  3. # Type="MYSQL"
  4. # HTTP="true"
  5. $hostname_actulizar_sistema = "localhost";
  6. $database_actulizar_sistema = "actualizar";
  7. $username_actulizar_sistema = "root";
  8. $password_actulizar_sistema = "";
  9. $actulizar_sistema = mysql_pconnect($hostname_actulizar_sistema, $username_actulizar_sistema, $password_actulizar_sistema) or trigger_error(mysql_error(),E_USER_ERROR);
  10. ?>
  11. <?php
  12. if (!function_exists("GetSQLValueString")) {
  13. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  14. {
  15. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  16.  
  17. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  18.  
  19. switch ($theType) {
  20. case "text":
  21. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  22. break;
  23. case "long":
  24. case "int":
  25. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  26. break;
  27. case "double":
  28. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  29. break;
  30. case "date":
  31. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  32. break;
  33. case "defined":
  34. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  35. break;
  36. }
  37. return $theValue;
  38. }
  39. }
  40.  
  41. $editFormAction = $_SERVER['PHP_SELF'];
  42. if (isset($_SERVER['QUERY_STRING'])) {
  43. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  44. }
  45.  
  46. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  47. $updateSQL = sprintf("UPDATE edicion SET telefono=%s WHERE nombre=%s",
  48. GetSQLValueString($_POST['telefono'], "text"),
  49. GetSQLValueString($_POST['nombre'], "text"));
  50.  
  51.  
  52. mysql_select_db($database_actulizar_sistema, $actulizar_sistema);
  53. $Result1 = mysql_query($updateSQL, $actulizar_sistema) or die(mysql_error());
  54. }
  55.  
  56. mysql_select_db($database_actulizar_sistema, $actulizar_sistema);
  57. $query_mod = "SELECT * FROM edicion ORDER BY nombre ASC";
  58. $mod = mysql_query($query_mod, $actulizar_sistema) or die(mysql_error());
  59. $row_mod = mysql_fetch_assoc($mod);
  60. $totalRows_mod = mysql_num_rows($mod);
  61. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <html xmlns="http://www.w3.org/1999/xhtml">
  63. <head>
  64. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  65. <title>Editar varios</title>
  66. <style type="text/css">
  67. <!--
  68. .Estilo1 {
  69. font-size: 24px;
  70. font-weight: bold;
  71. font-style: italic;
  72. color: #FF0000;
  73. }
  74. -->
  75. </style>
  76. </head>
  77.  
  78. <body>
  79. <p align="center" class="Estilo1">Editar varios Registros</p>
  80. <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  81. <table border="1" align="center">
  82. <tr align="center">
  83. <td><strong>Nombre y Apellidos</strong></td>
  84. <td><strong>Telfono</strong></td>
  85. </tr>
  86. <?php do { ?>
  87. <tr>
  88. <td><label>
  89. <input name="nombre" type="text" id="nombre" value="<?php echo $row_mod['nombre']; ?>" size="40" />
  90. </label></td>
  91. <td><label>
  92. <input name="telefono" type="text" id="telefono" value="<?php echo $row_mod['telefono']; ?>" size="20" />
  93. </label></td>
  94. </tr>
  95. <?php } while ($row_mod = mysql_fetch_assoc($mod)); ?>
  96. <tr>
  97. <td colspan="2" align="center"><label>
  98. <input type="submit" name="button" id="button" value="Guardar Cambios" />
  99. </label></td>
  100. </tr>
  101. </table>
  102. <input type="hidden" name="MM_update" value="form1" />
  103. </form>
  104. <p>&nbsp; </p>
  105. </body>
  106. </html>
  107. <?php
  108. ?>