Foros del Web » Programando para Internet » PHP »

Procesar actualizacion de registros

Estas en el tema de Procesar actualizacion de registros en el foro de PHP en Foros del Web. Hola que tal, miren estoy haciendo un sistema de altas, bajas y modificaciones. Pues bien estoy atorado en la parte de las modificaciones ya que ...
  #1 (permalink)  
Antiguo 20/08/2012, 16:15
 
Fecha de Ingreso: mayo-2012
Ubicación: Distrito Federal
Mensajes: 49
Antigüedad: 11 años, 10 meses
Puntos: 9
Pregunta Procesar actualizacion de registros

Hola que tal, miren estoy haciendo un sistema de altas, bajas y modificaciones.

Pues bien estoy atorado en la parte de las modificaciones ya que para realizarlas lo hago por medio de dos archivos, la primera es aquella en la que se muestran los datos a actualizar dependiendo de la busqueda (actualizar.php) y el segundo es el que se encarga de guardar los datos ya actualizados (actualizar_procesar.php).

Mi problemas es con este ultimo archivo, ya que no se como hacer para que me guarde los datos ya actualizados, espero que me puedan ayudar a resolver ste problema.

Aqui el codigo de los archivos:

busqueda.php
Código:
<?php require_once('Connections/futbol.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_mostrar_datos = "-1";
if (isset($_POST['busqueda'])) {
  $colname_mostrar_datos = $_POST['busqueda'];
}
mysql_select_db($database_futbol, $futbol);
$query_mostrar_datos = sprintf("SELECT * FROM datos_jugador WHERE nombre LIKE %s", GetSQLValueString("%" . $colname_mostrar_datos . "%", "text"));
$mostrar_datos = mysql_query($query_mostrar_datos, $futbol) or die(mysql_error());
$row_mostrar_datos = mysql_fetch_assoc($mostrar_datos);
$totalRows_mostrar_datos = mysql_num_rows($mostrar_datos);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Busqueda</title>

<style type="text/css">
<!--
#apDiv1 {
	position:absolute;
	width:817px;
	height:115px;
	z-index:1;
	left: 130px;
	top: 85px;
}
#apDiv2 {
	position:absolute;
	width:457px;
	height:46px;
	z-index:2;
	left: 326px;
	top: 21px;
}
-->
</style>
</head>

<body>
<div id="apDiv1">
  <table width="954" border="1">
    <tr>
      <td width="322">NOMBRE</td>
      <td width="140">APODO</td>
      <td width="182">NACIONALIDAD</td>
      <td width="138">ACTUALIZAR</td>
      <td width="138">BORRAR</td>
    </tr>
    <tr>
      <td><?php echo $row_mostrar_datos['nombre']; ?> <?php echo $row_mostrar_datos['ap_pat']; ?> <?php echo $row_mostrar_datos['ap_mat']; ?></td>
      <td><?php echo $row_mostrar_datos['apodo']; ?></td>
<td><?php echo $row_mostrar_datos['nacionalidad']; ?></td>
<td><a href="actualizar.php?id_jugador=<?php echo $row_mostrar_datos['id_jugador']; ?>" >ACTUALIZAR</a></td>
      <td><a href="eliminar.php?id_jugador=<?php echo $row_mostrar_datos['id_jugador']; ?>" >BORRAR</a></td>
    </tr>
  </table>
</div>
<div id="apDiv2">
  <form id="form1" name="form1" method="post" action="busqueda.php">
    ESCRIBE UN NOMBRE 
    <label>
      <input type="text" name="busqueda" id="busqueda" />
    </label>
    <label>
      <input type="submit" name="enviar" id="enviar" value="BUSCAR" />
    </label>
  </form>
</div>
</body>
</html>
<?php
mysql_free_result($mostrar_datos);
?>
actualizar.php
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Actualizar</title>
<style type="text/css">
<!--
#apDiv1 {
	position:absolute;
	width:948px;
	height:448px;
	z-index:1;
	left: 38px;
	top: 49px;
}
-->
</style>
</head>

<body>

<?php 

$conexion = mysql_connect ("localhost", "usuario", "pass");
mysql_select_db ("sistema");

$id_jugador=$_GET["id_jugador"];
$result=mysql_query("SELECT * FROM datos_jugador WHERE id_jugador = ".$id_jugador.";");
$row = mysql_fetch_array($result);

?>


<div id="apDiv1">
  <form action="actualizar_procesar.php?id_jugador=<? print $id_jugador; ?>" method="post" enctype="multipart/form-data" name="formDatos" id="formDatos">
    <p>NOMBRE: 
      <label>
        <input type="text" name="nombre" id="nombre" value= "<? print $row ['nombre']; ?>" placeholder="Escriba el nombre"  onkeyup="this.value=this.value.toUpperCase();"/>
      </label>
   &nbsp; APELLIDO PATERNO:
   <label>
     <input type="text" name="ap_pat" id="ap_pat" value= "<? print $row ['ap_pat']; ?>" placeholder="Escriba el apellido paterno"  onkeyup="this.value=this.value.toUpperCase();"/>
   </label>
   &nbsp; APELLIDO MATERNO: 
   <label>
     <input type="text" name="ap_mat" id="ap_mat" value= "<? print $row ['ap_mat']; ?>" placeholder="Escriba el apellido materno"  onkeyup="this.value=this.value.toUpperCase();"/>
   </label>
   <br />
    <br />
    APODO: 
    <label>
      <input type="text" name="apodo" id="apodo" value= "<? print $row ['apodo']; ?>" placeholder="Escriba el apodo"  onkeyup="this.value=this.value.toUpperCase();"/>
    </label>
    </p>
    <p>NACIONALIDAD: 
      <label>
        <input type="text" name="nacionalidad" id="nacionalidad" value= "<? print $row ['nacionalidad']; ?>" placeholder="Escriba la nacionalidad"  onkeyup="this.value=this.value.toUpperCase();"/>
      </label>
    </p>
    <p>EDAD: 
      <label>
        <input type="text" name="edad" id="edad" value= "<? print $row ['edad']; ?>" placeholder="Escriba la edad"  onkeyup="this.value=this.value.toUpperCase();"/>
      </label>
   AÑOS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ALTURA: 
   <label>
     <input type="text" name="altura" id="altura" value= "<? print $row ['altura']; ?>" placeholder="Escriba la altura"  onkeyup="this.value=this.value.toUpperCase();"/>
   </label>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PESO: 
   <label>
     <input type="text" name="peso" id="peso" value= "<? print $row ['peso']; ?>" placeholder="Escriba el peso"  onkeyup="this.value=this.value.toUpperCase();"/>
   </label>
    KG.</p>
<p>POSICION:&nbsp;
  <label>
    <select name="posicion" id="posicion" value= "<? print $row ['posicion']; ?>">
      <option selected="selected">Seleccione una posicion</option>
      <option value="PORTERO">PORTERO</option>
      <option value="DEFENSA">DEFENSA</option>
      <option value="MEDIO">MEDIO</option>
      <option value="DELANTERO">DELANTERO</option>
    </select>
  </label>
</p>
    <p>NUMERO: 
      <label>
        <input type="text" name="numero" id="numero" value= "<? print $row ['numero']; ?>" placeholder="Escriba el numero"  onkeyup="this.value=this.value.toUpperCase();"/>
      </label>
    </p>
    <p>IMAGEN: 
      <label>
        <input type="file" name="imagen" id="imagen"/>
      </label>
    </p>
    <p><img src="imagenes/imagenes_jugadores/<?php echo $row['imagen']; ?>" width="125" height="125" />&nbsp; IMAGEN ACTUAL</p>
    <p>HABILIDAD: 
      <label>
        <input type="text" name="habilidad" id="habilidad" value= "<? print $row ['habilidad']; ?>" placeholder="Escriba alguna habilidad"  onkeyup="this.value=this.value.toUpperCase();"/>
      </label>
    </p>
    <p>COMENTARIOS:
      <label>
        <textarea name="comentarios" id="comentarios" cols="30" rows="5" value= "<? print $row ['comentarios']; ?>" placeholder="Escriba algun comentario"  onkeyup="this.value=this.value.toUpperCase();"></textarea>
      </label>
      <br />
    </p>
    <p>
      <label>
        <input type="submit" name="enviar" id="enviar" value="GUARDAR DATOS" />
      </label>
    </p>
  </form>
</div>
</body>
</html>
Como les digo, no se como hacer el archivo actualizar_procesar.php que guarde los datos ya actualizados.

De antemano gracias por la ayuda.
  #2 (permalink)  
Antiguo 20/08/2012, 16:22
Avatar de rodrigo791  
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 4 meses
Puntos: 168
Respuesta: Procesar actualizacion de registros

para guardar los datos que el tipo actualiza, haces un UPDATE de TODOS los valores que te lleguen del formulario actualizar.php por metodo post en este caso.
O sea, desde actualizar_procesar.php 1ero capturas todos los datos, $_POST...blablabla.
y luego haces el update de esos datos, tan sencillo como eso

Etiquetas: html, mysql, procesar, registros, sql, actualizaciones, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:46.