Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/11/2012, 11:21
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 12 años, 6 meses
Puntos: 10
Respuesta: Pasar variable después hacer un update.

Gracias, por contestar. Me he equivocado y la variable era NUM_USUARIO que está mas abajo en el formulario que hago (antes se me olvido incluirla) que está en el select.
Lo vuelvo a poner:

Código Javascript:
Ver original
  1. <?php require_once('Connections/conexion.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form3")) {
  40.   $updateSQL = sprintf("UPDATE ap_usuarios SET MODELO=%s, MARCA=%s, APARATO=%s, COD_APARATO=%s, GRUPO=%s, NUM_PRODUCTO=%s, REVISION=%s, FD=%s, NUM_SERIE=%s, DISTRIBUIDOR=%s, ASEGURADORA=%s, FECHA_COMPRA=%s, INICIO_GARANTIA=%s, FIN_GARANTIA=%s WHERE NUM_APARATO=%s",
  41.                        
  42.                        GetSQLValueString($_POST['MODELO'], "text"),
  43.                        GetSQLValueString($_POST['MARCA'], "text"),
  44.                        GetSQLValueString($_POST['APARATO'], "text"),
  45.                        GetSQLValueString($_POST['COD_APARATO'], "text"),
  46.                        GetSQLValueString($_POST['GRUPO'], "text"),
  47.                        GetSQLValueString($_POST['NUM_PRODUCTO'], "text"),
  48.                        GetSQLValueString($_POST['REVISION'], "text"),
  49.                        GetSQLValueString($_POST['FD'], "text"),
  50.                        GetSQLValueString($_POST['NUM_SERIE'], "text"),
  51.                        GetSQLValueString($_POST['DISTRIBUIDOR'], "text"),
  52.                        GetSQLValueString($_POST['ASEGURADORA'], "text"),
  53.                        GetSQLValueString($_POST['FECHA_COMPRA'], "date"),
  54.                        GetSQLValueString($_POST['INICIO_GARANTIA'], "date"),
  55.                        GetSQLValueString($_POST['FIN_GARANTIA'], "date"),
  56.                        GetSQLValueString($_POST['NUM_APARATO'], "int"));
  57.  
  58.   mysql_select_db($database_conexion, $conexion);
  59.   $Result1 = mysql_query($updateSQL, $conexion) or die(mysql_error());
  60.  
  61.   $updateGoTo = "menu3.php?id=$NUM_USUARIO"; ///Lo estoy haciendo así pero sigue sin funcionar////
  62.   header("Location:$updateGoTo");
  63.   exit;
  64. }
  65. $num_aparato=$_GET['ID'];
  66. mysql_select_db($database_conexion, $conexion);
  67. $query_Recordset1 = "SELECT * FROM ap_usuarios where num_aparato = '$num_aparato'";
  68. $Recordset1 = mysql_query($query_Recordset1, $conexion) or die(mysql_error());
  69. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  70. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  71. ?>
  72. <form method="post" name="form3" action="<?php echo $editFormAction; ?>">
  73. <table width="100%">
  74.   <tr>
  75.     <td>Aparato</td>
  76.     <td><input name="APARATO" type="text" value="<?php echo $row_Recordset1['APARATO']; ?>" /></td>
  77.     <td>Modelo</td>
  78.     <td><input name="MODELO" type="text" value="<?php echo $row_Recordset1['MODELO']; ?>" /></td>
  79.     <td>NºSerie</td>
  80.     <td><input name="NUM_SERIE" type="text" value="<?php echo $row_Recordset1['NUM_SERIE']; ?>" /></td>
  81.   </tr>
  82.   <tr>
  83.     <td>Marca</td>
  84.     <td><input name="MARCA" type="text" value="<?php echo $row_Recordset1['MARCA']; ?>" /></td>
  85.     <td>Cod/12Nc</td>
  86.     <td><input name="NUM_PRODUCTO" type="text" value="<?php echo $row_Recordset1['NUM_PRODUCTO']; ?>" /></td>
  87.     <td>Revisión</td>
  88.     <td><input name="REVISION" type="text" /></td>
  89.   </tr>
  90.   <input type="hidden" name="MM_update" value="form3">
  91.   <input type="hidden" name="NUM_APARATO" value="<?php echo $row_Recordset1['NUM_APARATO']; ?>">
  92.   <input type="hidden" name="NUM_USUARIO" value="<?php echo $row_Recordset1['NUM_USUARIO']; ?>">
  93.   </table>
  94.   </form>
  95. <?php
  96. mysql_free_result($Recordset1);
  97. ?>

Código Javascript:
Ver original
  1. $updateGoTo = "menu3.php?id=$NUM_USUARIO"; ///Lo estoy haciendo así pero sigue sin funcionar////

Código Javascript:
Ver original
  1. <input type="hidden" name="NUM_USUARIO" value="<?php echo $row_Recordset1['NUM_USUARIO']; ?>">

Gracias.