Foros del Web » Programando para Internet » PHP »

problemas con update

Estas en el tema de problemas con update en el foro de PHP en Foros del Web. lo que quiero que se modifique es esto Código HTML: <?php if(isset($_GET['m'])){ $modificar=mysql_fetch_array(mysql_query("SELECT id,pregunta FROM tbl_encuestasp WHERE id= ".$_GET['id'])); $modificaropciones=mysql_query(" SELECT idpregunta,respuesta FROM tbl_encuestasr WHERE ...

  #1 (permalink)  
Antiguo 09/09/2010, 08:12
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Exclamación

lo que quiero que se modifique es esto


Código HTML:
<?php if(isset($_GET['m'])){
	   $modificar=mysql_fetch_array(mysql_query("SELECT id,pregunta  FROM tbl_encuestasp WHERE id=".$_GET['id']));
	   $modificaropciones=mysql_query("SELECT idpregunta,respuesta FROM tbl_encuestasr WHERE idpregunta=".$_GET['id']);
	   ?>



<form id="Modificar" name="form1"  method="POST" action="adminencuesta.php">
<table align="center" border="0">
  <tr>
    <td height="48"width="342">Modifica la pregunta:
    
      <input  name="pregunta" type="text" id="pregunta" value="<?php echo($modificar['pregunta']);?>"  size="40"  maxlength="51" align="left" />
      <br /></td>
  </tr>
  	
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="42">modifica la opcion 1:
    <?php $data=mysql_fetch_assoc($modificaropciones);?>
    <input name="modopcion1" type="text" id="opcion1" value="<?php echo($data['respuesta']);?>" size="30"    maxlength="28" /></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="42">modifica la opcion 2:
       <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30"  maxlength="28"/></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>   
    <td height="49">modifica la opcion 3:
      <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input type="text" id="opcion3"  name="opcion3"size="30" value="<?php echo($data['respuesta']);?>"   maxlength="28"/></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="43">modifica la opcion 4:
       <?php  /*if($data=mysql_fetch_assoc($modificarocpiones)){
		$opcion4=$data['respuesta'];
	   }else{
			$o="";   
	   }*/?>
       <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input type="text" id="opcion4" name="opcion4" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
      
  </tr>
</table>
<input name="modificar" type="submit" id="modificar"value="modificar" onClick="MM_validateForm('pregunta','','R','opcion1','','R','opcion2','','R');return document.MM_returnValue"   />
</form> 


lo que no me funca es que arriba de todo yo hago esto


if(isset($_POST['modificar'])){
mysql_query("UPDATE tbl_encuestasp SET pregunta='".$_POST['pregunta'] ."' WHERE id=".$_POST['id']);

}



if(isset($_POST['Modificaropciones'])){
mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['respuesta']."' WHERE idpregunta=".$_POST['id']);

}




QUE ALGUIEN ME AYUDE PORFAVOR

[IMG]C:\Documents and Settings\eguzman\Mis documentos\Downloads[/IMG]

eso es

si necesitan todo el codigo diganme

Última edición por GatorV; 09/09/2010 a las 08:36
  #2 (permalink)  
Antiguo 09/09/2010, 08:17
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 2 meses
Puntos: 55
Respuesta: problemas con update

y el $_POST['id'] ?? de donde lo sacas ?? en el forma no tienes el id
  #3 (permalink)  
Antiguo 09/09/2010, 08:19
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

entonces que tendira que poner ahi? o en el form que tendria que agregar?
  #4 (permalink)  
Antiguo 09/09/2010, 08:22
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 2 meses
Puntos: 55
Respuesta: problemas con update

algo como
Código PHP:
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
  #5 (permalink)  
Antiguo 09/09/2010, 08:23
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
en el final del form? en que parte, ya lo intente a eso me parece

ah lo agregue, modifica la pregunta, con las opciones tendria que hacer un while?? porque las opciones son de otra tabla

Última edición por GatorV; 09/09/2010 a las 08:37
  #6 (permalink)  
Antiguo 09/09/2010, 08:27
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

Código PHP:
Ver original
  1. <form id="Modificar" name="form1"  method="POST" action="adminencuesta.php">
  2. <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">

ponlo asi para que el hidden quede dentro del form
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #7 (permalink)  
Antiguo 09/09/2010, 08:30
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

listo la opcion modifica, las preguntas como haria, fijate quemi consulta de


if(isset($_POST['Modificaropciones'])){
mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['respuesta']."' WHERE idpregunta=".$_POST['id']);

}


ni registra,
  #8 (permalink)  
Antiguo 09/09/2010, 08:34
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

Si vas a validar el $POST del submit tendrias que poner el nombre del submit en este caso sería:

Código PHP:
Ver original
  1. if($_POST['modificar']){
  2. ..
  3. ...
  4. ...
  5. }
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #9 (permalink)  
Antiguo 09/09/2010, 08:37
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

lo de modificar la pregunta lo solucione gracias a las respuestas de arriba , lo que quiero que modifique son las opciones

Cita:
if(isset($_POST['Modificaropciones'])){
mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['respuesta']."' WHERE idpregunta=".$_POST['id']);

}
l

Última edición por eke_ps; 09/09/2010 a las 08:38 Razón: actualizar
  #10 (permalink)  
Antiguo 09/09/2010, 08:45
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

en la misma validación del submit donde modificas la pregunta puedes poner el query para modifcar las opciones

"Update tbl_encuestas set opcion1="nombre del input del form" where id=".$_POT['id']
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #11 (permalink)  
Antiguo 09/09/2010, 08:51
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

if(isset($_POST['modificar'])){
mysql_query("UPDATE tbl_encuestasp SET pregunta='".$_POST['pregunta'] ."' WHERE id=".$_POST['id']);
mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['form1'] ." where id=".$_POST['id']);


}



eso no funciona, seguro puse algo mal
  #12 (permalink)  
Antiguo 09/09/2010, 08:58
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

Y en que parte del form esta para modficar la respuesta???,

Código HTML:
<form id="Modificar" name="form1"  method="POST" action="adminencuesta.php">
<table align="center" border="0">
  <tr>
    <td height="48"width="342">Modifica la pregunta:
    
      <input  name="pregunta" type="text" id="pregunta" value="<?php echo($modificar['pregunta']);?>"  size="40"  maxlength="51" align="left" />
      <br /></td>
  </tr>
  	
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="42">modifica la opcion 1:
    <?php $data=mysql_fetch_assoc($modificaropciones);?>
    <input name="modopcion1" type="text" id="opcion1" value="<?php echo($data['respuesta']);?>" size="30"    maxlength="28" /></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="42">modifica la opcion 2:
       <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30"  maxlength="28"/></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>   
    <td height="49">modifica la opcion 3:
      <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input type="text" id="opcion3"  name="opcion3"size="30" value="<?php echo($data['respuesta']);?>"   maxlength="28"/></td>
  </tr>
   <tr><td height="1" bgcolor="#000000"></td></tr>
  <tr>
    <td height="43">modifica la opcion 4:
       <?php  /*if($data=mysql_fetch_assoc($modificarocpiones)){
		$opcion4=$data['respuesta'];
	   }else{
			$o="";   
	   }*/?>
       <?php $data=mysql_fetch_assoc($modificaropciones);?>
      <input type="text" id="opcion4" name="opcion4" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
      
  </tr>
</table>
<input name="modificar" type="submit" id="modificar"value="modificar" onClick="MM_validateForm('pregunta','','R','opcion1','','R','opcion2','','R');return document.MM_returnValue"   />
</form> 
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #13 (permalink)  
Antiguo 09/09/2010, 09:03
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

soy principiante , hace una semana agarre esto de php con mysql, lo que decis no es eso qe hago aca?

Cita:
<td height="42">modifica la opcion 2:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
  #14 (permalink)  
Antiguo 09/09/2010, 09:07
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

ese es el input donde vas a modificar la respuesta?... entonces sería asi:

Código PHP:
Ver original
  1. if(isset($_POST['modificar'])){
  2.  
  3. mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['opcion2'] ." where id=".$_POST['id']);

En el update debes de poner el $POST con el atributo name del input no su value:

<input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #15 (permalink)  
Antiguo 09/09/2010, 09:11
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

puse esto y no funciono

if
Cita:
(isset($_POST['modificar'])){
mysql_query("UPDATE tbl_encuestasp SET pregunta='".$_POST['pregunta'] ."' WHERE id=".$_POST['id']);
//mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['respuesta'] ." where idpregunta=".$_POST['id']);
mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['modopcion1'] ." where id=".$_POST['id']);


}

y la opcion que quise modificar es esta


Cita:
<td height="42">modifica la opcion 1:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="modopcion1" type="text" id="opcion1" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28" /></td>
  #16 (permalink)  
Antiguo 09/09/2010, 09:16
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

Código PHP:
Ver original
  1. mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE id=".$_POST['id'])or die(mysql_error());

ponlo asi para ver que error te muestra
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #17 (permalink)  
Antiguo 09/09/2010, 09:17
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

absolutamente ningun error
  #18 (permalink)  
Antiguo 09/09/2010, 09:19
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

se modifican todas las respuestas

mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE idpregunta=".$_POST['id'])or die(mysql_error());



se modifican todas si modifico la primera ahora


<td height="42">modifica la opcion 1:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="modopcion1" type="text" id="opcion1" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28" /></td>
</tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="42">modifica la opcion 2:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
</tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="49">modifica la opcion 3:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input type="text" id="opcion3" name="opcion3"size="30" value="<?php echo($data['respuesta']);?>" maxlength="28"/></td>
  #19 (permalink)  
Antiguo 09/09/2010, 09:20
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE id=".$_POST['id'])or die(mysql_error());

ese id de que es?...... tienes una tabla de respuestas que se relacionan con la pregunta?.....o en tu tabla de preguntas tienes un campo con la respuesta?
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #20 (permalink)  
Antiguo 09/09/2010, 09:22
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

tengo na tabla de respuestas que se relaciona con la pregunta

son respuestas que tienen idpregunta
  #21 (permalink)  
Antiguo 09/09/2010, 09:22
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

si pongo esto

mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE idpregunta=".$_POST['id'])or die(mysql_error());

modifico la opcion 1 y modifican todas
  #22 (permalink)  
Antiguo 09/09/2010, 09:26
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

pero como se llaman los campos de tu tabla porq podrias ponerlo asi:

mysql_query("UPDATE tbl_encuestasr SET respuesta1='".$_POST['modopcion1'] ."' WHERE idpregunta=".$_POST['id'])or die(mysql_error());

pero si pudieras mostrar la estructura de tu tabla seria mucho merjor, porque no te deberia de modificar todas las respuestas solo la que quieres modificar
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #23 (permalink)  
Antiguo 09/09/2010, 09:27
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

es asi la tabla de las respuestas


id idpregunta respuesta
22 1 lala



si a eso te refieres es asi la tabla, con 3 columnas solamente
  #24 (permalink)  
Antiguo 09/09/2010, 09:30
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

se siguen modificando todas



if(isset($_POST['modificar'])){
mysql_query("UPDATE tbl_encuestasp SET pregunta='".$_POST['pregunta'] ."' WHERE id=".$_POST['id']);
//mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['respuesta'] ." where idpregunta=".$_POST['id']);
mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE idpregunta=".$_POST['id'])or die(mysql_error());
//mysql_query("UPDATE tbl_encuestasr set respuesta=".$_POST['modopcion1'] ." WHERE idpregunta=".$_POST['id']);


}















y te muestro el form de paso


Cita:
<?php if(isset($_GET['m'])){
$modificar=mysql_fetch_array(mysql_query("SELECT id,pregunta FROM tbl_encuestasp WHERE id=".$_GET['id']));
$modificaropciones=mysql_query("SELECT idpregunta,respuesta FROM tbl_encuestasr WHERE idpregunta=".$_GET['id']);
?>

<form id="Modificar" name="form1" method="POST" action="adminencuesta.php">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<table align="center" border="0">
<tr>
<td height="48"width="342">Modifica la pregunta:

<input name="pregunta" type="text" id="pregunta" value="<?php echo($modificar['pregunta']);?>" size="40" maxlength="51" align="left" />
<br /></td>
</tr>

<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="42">modifica la opcion 1:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="modopcion1" type="text" id="opcion1" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28" /></td>
</tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="42">modifica la opcion 2:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input name="opcion2" type="text" id="opcion2" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>
</tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="49">modifica la opcion 3:
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input type="text" id="opcion3" name="opcion3"size="30" value="<?php echo($data['respuesta']);?>" maxlength="28"/></td>
</tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr>
<td height="43">modifica la opcion 4:
<?php /*if($data=mysql_fetch_assoc($modificarocpiones)){
$opcion4=$data['respuesta'];
}else{
$o="";
}*/?>
<?php $data=mysql_fetch_assoc($modificaropciones);?>
<input type="text" id="opcion4" name="opcion4" value="<?php echo($data['respuesta']);?>" size="30" maxlength="28"/></td>

</tr>
</table>
<input name="modificar" type="submit" id="modificar"value="modificar" onClick="MM_validateForm('pregunta','','R','opcion 1','','R','opcion2','','R');return document.MM_returnValue" />
</form>
  #25 (permalink)  
Antiguo 09/09/2010, 09:30
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

entonces en esa tabla puedes tener esto no?

id idpregunta respuesta
1 2 lolo
2 2 lala

si es asi podrías hacer esto:

mysql_query("UPDATE tbl_encuestasr SET respuesta='".$_POST['modopcion1'] ."' WHERE idpregunta=".$_POST['id'] AND id = 1)or die(mysql_error());

por decir algo ya que una pregunta puede tener muchas respuestas relacionadas con ella, pero cada registro de tu campo respuestas es unico gracias a su id que le asignaste,
captas la idea?
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #26 (permalink)  
Antiguo 09/09/2010, 09:33
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

ese AND id=1 no podria agregar, porqe en la pagina hay otra opcion que agrega preguntas y respuestas nuevas
  #27 (permalink)  
Antiguo 09/09/2010, 09:36
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

a ver a ver estas actualizando los registros de tu tabla respuestas o estan insertando registros?????
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #28 (permalink)  
Antiguo 09/09/2010, 09:38
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

actualizando, pero en otro archivo se agregan, entonces cuando agregue el usuario una nueva encuesta no se podra modificar ya que no tiene acceso a poner AND= 2 o 3 o 4...

estoy actualizando si...
  #29 (permalink)  
Antiguo 09/09/2010, 09:47
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: problemas con update

a ver cuando actualizas un registro este registro normalmente se pasa de parametro el id de ese registro ya que por lo general ese id es único, osea que no se repite, mientras que al insertar un nuevo registro no se tiene porque poner el AND id = 2, ya que si tu campo id lo definiste como autoincrementable al momento de crear tu base de datos no tienes porque ponerlo en el query de mysql

mira un ejemplo:

id idpreg texto

si el id es autoincremetable el insert quedaria asi:

Código PHP:
Ver original
  1. "insert into tabla(idpreg,texto) values('"$algo"','"$algo2"')";

mientras que al actualizar seria:

Código PHP:
Ver original
  1. "update tabla set texto='"$algo"' where idpreg=".$idpre." and id="$id_del_registro;

aqui mandas como parametro que se modifica la respuesta que esta relacionada a una pregunta, pero como puedes tener más de una respuesta a esa pregunta pues debes indicarle cual de todas tus respuestas a esa pregunta deseas modificar

un poco más entendible???
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---
  #30 (permalink)  
Antiguo 09/09/2010, 09:49
 
Fecha de Ingreso: septiembre-2010
Mensajes: 101
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: problemas con update

si ahora si, que paciencia tenes amigo, aunque esta mierda sigue modificando todas

Etiquetas: update
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 01:01.