Ver Mensaje Individual
  #24 (permalink)  
Antiguo 21/11/2013, 18:11
ghiovani_999
 
Fecha de Ingreso: noviembre-2013
Mensajes: 11
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: Actualizar Múltiples Registros Php y Mysql

Hola tranquilo_8925, creo que has culminado con el problema de actualizar "Múltiples registros ", la verdad me interesa mucho esa aplicación pequeña, porque serviría para presentar mi pequeño proyecto en mi instituto.... podrias pasarte todo el codigo de tu exito..... mi correo es [email protected] te lo agradeseria muchisimo de verdad.... e estado investigando el tema es un complicadisimo para mi. Igualmente agradesco ha "nedyer " que brinda sus aportes de conocimiento, gracias a DIOS que te bendicio por ese conocimiento...porfavor ayudeme a solucionar el problema de actualizar multiples registros..... no entiendo este codigo:
Código PHP:
Ver original
  1. <?php require_once('../Connections/actulizar_sistema.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  
  8. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  9.  
  10. switch ($theType) {
  11. case "text":
  12. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13. break;
  14. case "long":
  15. case "int":
  16. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17. break;
  18. case "double":
  19. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  20. break;
  21. case "date":
  22. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23. break;
  24. case "defined":
  25. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26. break;
  27. }
  28. return $theValue;
  29. }
  30. }
  31.  
  32. $editFormAction = $_SERVER['PHP_SELF'];
  33. if (isset($_SERVER['QUERY_STRING'])) {
  34. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  35. }
  36.  
  37. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  38. //$updateSQL = sprintf("UPDATE edicion SET telefono=%s WHERE nombre=%s",
  39. $updateSQL = sprintf("UPDATE edicion SET telefono=%s WHERE nombre=$value",
  40. GetSQLValueString($_POST['telefono'], "text"),
  41. GetSQLValueString($_POST['nombre'], "text"));
  42.  
  43.  
  44. mysql_select_db($database_actulizar_sistema, $actulizar_sistema);
  45. $Result1 = mysql_query($updateSQL, $actulizar_sistema) or die(mysql_error());
  46. }
  47.  
  48. mysql_select_db($database_actulizar_sistema, $actulizar_sistema);
  49. $query_mod = "SELECT * FROM edicion ORDER BY nombre ASC";
  50. $mod = mysql_query($query_mod, $actulizar_sistema) or die(mysql_error());
  51. $row_mod = mysql_fetch_assoc($mod);
  52. $totalRows_mod = mysql_num_rows($mod);
  53. ?>
  54. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  55. <html xmlns="http://www.w3.org/1999/xhtml">
  56. <head>
  57. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  58. <title>Editar varios</title>
  59. <style type="text/css">
  60. <!--
  61. .Estilo1 {
  62. font-size: 24px;
  63. font-weight: bold;
  64. font-style: italic;
  65. color: #FF0000;
  66. }
  67. -->
  68. </style>
  69. </head>
  70.  
  71. <body>
  72. <p align="center" class="Estilo1">Editar varios Registros</p>
  73. <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  74. <table border="1" align="center">
  75. <tr align="center">
  76. <td><strong>Nombre y Apellidos</strong></td>
  77. <td><strong>Telfono</strong></td>
  78. </tr>
  79. <?php do { ?>
  80. <tr>
  81. <td><label>
  82. <input name="nombre" type="text" id="nombre" value="<?php echo $row_mod['nombre']; ?>" size="40" />
  83. </label></td>
  84. <td><label>
  85. <input name="telefono" type="text" id="telefono" value="<?php echo $row_mod['telefono']; ?>" size="20" />
  86. </label></td>
  87. </tr>
  88. <?php } while ($row_mod = mysql_fetch_assoc($mod)); ?>
  89. <tr>
  90. <td colspan="2" align="center"><label>
  91. <input type="submit" name="button" id="button" value="Guardar Cambios" />
  92. </label></td>
  93. </tr>
  94. </table>
  95. <input type="hidden" name="MM_update" value="form1" />
  96. </form>
  97. <p>&nbsp; </p>
  98. </body>
  99. </html>
  100. <?php
  101. ?>
Porfis, si ya te salio ayudama a completarlo plis: tranquilo_8925 y nedyer (ayudame o dile a tu pata tranquilo... porfis , este problema no me deja dormir). Gracias de antemano. estare pendiente a la respuesta.