Foros del Web » Programando para Internet » PHP »

Problema actualizar datos

Estas en el tema de Problema actualizar datos en el foro de PHP en Foros del Web. Un usuario tiene varios estudios, cada uno de los cuales tiene los campos: fecha inicio, fecha fin, titulo, especialidad, centro, modificar, borrar Ej: -------------------------------------------------------------------------------------------- Fecha ...
  #1 (permalink)  
Antiguo 24/06/2009, 05:42
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Problema actualizar datos

Un usuario tiene varios estudios, cada uno de los cuales tiene los campos: fecha inicio, fecha fin, titulo, especialidad, centro, modificar, borrar

Ej:
--------------------------------------------------------------------------------------------
Fecha inicio | Fecha fin | Titulo | Especialidad | Centro | Modificar | borrar |
---------------------------------------------------------------------------------------------
22-03-2000 30-12-2000 inform. gestion universi X X |
12-04-2002 30-09-2003 ingeni electronica universi X X |
---------------------------------------------------------------------------------------------

Siendo las "X" una imagen.
Lo que quiero es que al pulsar a la X me vaya a la página de modificar los datos y que éstos se muestren, lo que pasa es que siempre se me muestran los del primer registro... y claro, si pulso modificar el segundo registro lo que quiero es que se muestren los del 2º....

Cómo lo hago?
  #2 (permalink)  
Antiguo 24/06/2009, 05:44
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Problema actualizar datos

Muestra el codigo de como haces los enlaces y como los recibes para crear el formulario, solo asi podemos ver donde esta el error.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 24/06/2009, 05:47
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

Código HTML:
 <table width="100%">
        <!--DWLayoutTable-->
        <tr valign="top">
          <td width="200" height="286" rowspan="5" align="left"><img src="imagenes/menuRegistro3.jpg" width="200" height="286" /></td>
          <td width="1" height="100%" rowspan="5" align="left" bgcolor="#000166"><img src="transparent-wedge.gif" width="1" height="100%" /></td>
          <td height="43" colspan="2" align="left" valign="middle" class="tituloRegistro"><img src="imagenes/estudios.PNG" width="42" height="42" /> ESTUDIOS</td>
        </tr>
        <tr valign="top">
          <td height="2" colspan="2" bgcolor="#FF0000"><img src="transparent-wedge.gif" width="100%" height="2" /></td>
        </tr>
        <tr valign="top">
          <td height="40" colspan="2" valign="middle" class="TextoNormal"><strong><span class="Estilo5">&gt;&gt;</span> Estos son tus estudios acad&eacute;micos. </strong></td>
        </tr>
        <tr valign="top">
          <td height="164" colspan="2" align="center" valign="top" class="TextoNormal"><form id="form1" name="form1" method="post" action="meterExperiencia.php">
            <table width="100%" border="1" bgcolor="#FFFF66">
              <tr bgcolor="#99FF00">
                <td width="17%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>PERIODO</b></td>
                <td width="20%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>T&Iacute;TULO</b></td>
                <td width="23%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>ESPECIALIDAD</b></td>
                <td width="14%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>CENTRO</b></td>
                <td width="16%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>MODIFICAR</b></td>
                <td width="10%" align="center" bgcolor="#FFFF66" class="FuenteRegistro"><b>BORRAR</b></td>
              </tr>
			  
			   <? $Nif=$_POST['Nif'];  //$Nif="71287936B";  
          //echo "ESTO ES EL DNI ";
          //echo  "<BR>";
          //echo $Nif;
     ?>
			  <input type="hidden" value=<?php echo $Nif;?> name="Nif">
                   <?

include("conexion.php");

$sql="SELECT * FROM candidatoestudio3 WHERE nifCandidato='$Nif'"; 

$result=mysql_query("$sql",$conexion) or die(mysql_error());

echo "<table border = '1' bgcolor='#FFFF66' width='100%'> \n";

if(mysql_num_rows ($result) == 0){

echo "<td align='center' width='23%'>Sin periodo</td> \n";
	echo "<td align='center' width='15%'>Sin titulo</td> \n";
	echo "<td align='center' width='21%'>Ninguna</td> \n";
	echo "<td align='center' width='12%'>Ninguno</td> \n";
	echo "<td width='16%' align='center'><b><img src='imagenes/iconoModificar2.gif' width='29' height='27' /></b></td> \n";
	echo "<td width='13%' align='center'><b><img src='imagenes/papelera.gif' width='22' height='26' /></b></td> \n";
	echo "</tr> \n";
}
else{

while ($row = mysql_fetch_row($result)){
	
	$p=$row[3];
	$j=$row[1];
    $t=$row[2];

//echo $j;
$sql2="SELECT * FROM estudio WHERE idEstudio='$j'"; 
$result2=mysql_query("$sql2",$conexion) or die(mysql_error());
while ($row2 = mysql_fetch_row($result2)){
	//echo "<td>$row2[0]</td> \n";
    //echo "<td align='center' width='23%'>$p</td> \n";

    echo "<td align='center' width='17%'>$t<br>$p</td> \n";
	echo "<td align='center' width='20%'>$row2[1]</td> \n";
	echo "<td align='center' width='23%'>$row2[2]</td> \n";
	echo "<td align='center' width='14%'>$row2[3]</td> \n";
	echo "<td width='16%' align='center'><a href='modificar_estudios.php'><b><img src='imagenes/iconoModificar2.gif' width='29' height='27' border='0'/></b></td> \n";
	echo "<td width='10%' align='center'><b><img src='imagenes/papelera.gif' width='22' height='26' /></b></td> \n";
	echo "</tr> \n";
}
}}
//echo "</table> \n";
?>
              
              <tr>
                <td height="40" colspan="6" align="center"><input name="AnadirEstudios" type="button" class="TextoNormal" id="AnadirEstudios" value="A&ntilde;adir estudios" onclick = "location='meterEstudios.php'"/></td>
              </tr>
            </table>
                 <table width="100%">
              <tr>
                <td width="79%" align="center" valign="bottom"><img src="imagenes/guardar.PNG" width="288" height="32" hspace="150" /></td>
                <td width="21%" align="center" valign="bottom"><input name="image" type="image" src="imagenes/siguiente.PNG" /></td>
              </tr>
            </table>
			</form>		  
        </tr>
      </table> 
  #4 (permalink)  
Antiguo 24/06/2009, 06:02
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

He probado también a poner esto y tampoco me funciona:

<a href='modificar_estudios.php?Nif=<%=$Nif%>&idEstud io=<%=$j%>>'>
  #5 (permalink)  
Antiguo 24/06/2009, 06:04
Avatar de gjx2  
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: Problema actualizar datos

Pues veo que aqui

<a href='modificar_estudios.php'> No pasa ningun Nif a el archivo Modificar_estudios.pgp

Deberias pasar el Nif que quieres consultar.
Ejm.

<a href='modificar_estudios.php?Nif=2323234'>

Y luego en

Modificar_estudios.php

Código PHP:

$Nif 
$_GET["Nif" ];
$sql="SELECT * FROM candidatoestudio3 WHERE nifCandidato='$Nif'"
  #6 (permalink)  
Antiguo 24/06/2009, 06:08
Avatar de gjx2  
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: Problema actualizar datos

Intenta de esta forma

Código PHP:

<a href='modificar_estudios.php?Nif=<?=$Nif?>&idEstudio=<?=$j?>'>
  #7 (permalink)  
Antiguo 24/06/2009, 10:02
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

Me sigue pasando lo mismo... me sale el 1º...

En el juego de registros tengo:

SELECT fechaInicio, fechaFin, titulo, especialidad, centro
FROM candidatoestudio3, estudio, candidato
WHERE candidato.nifCandidato= candidatoestudio3.nifCandidato AND candidatoestudio3.idEstudio=estudio.idEstudio

Así que no entiendo porqué no muestra los datos si con el href ya le paso el nif y el idEstudio...
  #8 (permalink)  
Antiguo 24/06/2009, 10:11
Avatar de acoevil  
Fecha de Ingreso: julio-2008
Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 15 años, 8 meses
Puntos: 32
Respuesta: Problema actualizar datos

Cuando generas los enlaces hacia la pagina que modificar el estudio, te aseguraste de generarlos bien? es decir

<a href='index.php?md=1'>...</a>
<a href='index.php?md=2'>...</a>
<a href='index.php?md=3'>...</a>

Cuando pulsas cualquier enlace ves que va cambiando la URL?
  #9 (permalink)  
Antiguo 24/06/2009, 10:33
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

Sí, eso está bien.
Veo en la barra de direcciones y en la de estado que los parámetros que se pasan son correctos, así que el problema le tendré en modificar_estudios.php

Me da la sensación de que al pasar esos parámetros tendría que cambiar el juego de registros que he puesto más arriba, no?
  #10 (permalink)  
Antiguo 24/06/2009, 10:38
Avatar de acoevil  
Fecha de Ingreso: julio-2008
Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 15 años, 8 meses
Puntos: 32
Respuesta: Problema actualizar datos

Ok intenta algo como esto, cuando alguien pulse en el link

<a href='index.php?md=3'>...</a>

verifica que md te este llegando a la pagina con algun valor

echo $_GET['md']; // -> Deberia imprimir el 3

Si te llega el valor puede ser que la consulta la estes haciendo mal o no estes seleccionando el registro adecuadamente algo como esto...


$registro=mysql_query("select * from registros where codigo='".$_GET['md']."'");
  #11 (permalink)  
Antiguo 24/06/2009, 10:48
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

He hecho la comprobación y no me llega el valor... por qué?
  #12 (permalink)  
Antiguo 24/06/2009, 11:00
Avatar de acoevil  
Fecha de Ingreso: julio-2008
Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 15 años, 8 meses
Puntos: 32
Respuesta: Problema actualizar datos

Cita:
Iniciado por una_xikilla Ver Mensaje
He hecho la comprobación y no me llega el valor... por qué?
podrias ponerme el link que generas?
  #13 (permalink)  
Antiguo 24/06/2009, 11:04
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

He puesto el que me habías dicho tú:

<a href='modificar_estudios.php?Nif=<?=$Nif?>&idEstud io=<?=$j?>'>

Y como te he dicho antes los valores son correctos (lo veo en la barra de estado...), solo con pasar el ratón veo como el valor de idEstudio cambia dependiendo del registro...
Así q parece como si estuviera bien...
  #14 (permalink)  
Antiguo 24/06/2009, 15:27
Avatar de acoevil  
Fecha de Ingreso: julio-2008
Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 15 años, 8 meses
Puntos: 32
Respuesta: Problema actualizar datos

<a href='modificar_estudios.php?Nif=<?=$Nif?>&idEstud io=<?=$j?>'>
Ok dices que te genera bien los links, ahora en el archivo donde recojes la informacion lo haces asi?

echo $_GET['Nif'];

echo $_GET['idEstudio'];

Dale asi a ver si imprime.
  #15 (permalink)  
Antiguo 25/06/2009, 06:12
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

Sí, lo he hecho así.

He utilizado GET y POST y nada, no lo recoge....
  #16 (permalink)  
Antiguo 25/06/2009, 13:22
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Problema actualizar datos

Si el enlace esta bien, para ver lo que estas recibiendo y darte una idea de como obtenerlo correctamente en tu codigo:

Código php:
Ver original
  1. echo '<pre>';
  2. var_dump($_GET, $_POST);
  3. echo '</pre>';
__________________
- León, Guanajuato
- GV-Foto
  #17 (permalink)  
Antiguo 28/07/2009, 09:56
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Problema actualizar datos

Pues no me sale...

POR FAVOR, NECESITO AYUDA!!!

Por que tengo que hacer más páginas similares y me pasa exáctamente lo mismo...

Si por casualidad alguien me quiere ayudar por messenger o por correo si le viene mejor que me lo diga...

y sino pues por este foro.

Es que no entiendo porqué no salen los datos!!!
  #18 (permalink)  
Antiguo 28/07/2009, 10:02
 
Fecha de Ingreso: enero-2009
Mensajes: 408
Antigüedad: 15 años, 2 meses
Puntos: 14
Respuesta: Problema actualizar datos

Cita:
Iniciado por una_xikilla Ver Mensaje
Pues no me sale...

POR FAVOR, NECESITO AYUDA!!!

Por que tengo que hacer más páginas similares y me pasa exáctamente lo mismo...

Si por casualidad alguien me quiere ayudar por messenger o por correo si le viene mejor que me lo diga...

y sino pues por este foro.

Es que no entiendo porqué no salen los datos!!!
te dejo mi msn en un mp para ayudarte saludos!.
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 18:30.