Foros del Web » Programando para Internet » PHP »

Actualizar multiples registros, no actualiza

Estas en el tema de Actualizar multiples registros, no actualiza en el foro de PHP en Foros del Web. Hola migos de foros del web, siempre me han sido de gran ayuda sus comentarios y aportes y poco a poco voy aprendiendo de todos ...
  #1 (permalink)  
Antiguo 20/06/2011, 17:24
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Actualizar multiples registros, no actualiza

Hola migos de foros del web, siempre me han sido de gran ayuda sus comentarios y aportes y poco a poco voy aprendiendo de todos ustedes.....

Necesito modificar un campo check box de multiples registros y estoy atorado en esto, ojala algun amigo me puede decir mi error:


Este es el pedacito que segun he leido en este foro debe estar asi, en mi pagina de consulta:


<form action="modificar.php" method="POST" name="form1" id="form1">
<input type="checkbox" name="movi" value= "$row_datos['movi']" />
</label>
<input type="hidden" name="ID" value="$row_datos['ID']"/></td>


y este es el codigo en la pagina que realiza la acción:

<?php require_once('Connections/movi.php');

?>
<?php
$prueba = $_POST['ID'];
$nombre = $_POST['movi'];
mysql_query("UPDATE pedido SET movi='$nombre' WHERE id='$prueba'");

?>

<BR>
<Center>
<A HREF="pedir.php"> Regresar </A>
</Center>


Donde esta mi error, que estoy haciendo mal?
Como veran apenas son mis inicios en php

saludos!!!!
  #2 (permalink)  
Antiguo 20/06/2011, 17:29
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

bueno haz 2 cosas

un var_dump a cada variable

y coloca la linea de actualizar asi

mysql_query("UPDATE pedido SET movi='$nombre' WHERE id='$prueba'") or die (mysql_error());
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #3 (permalink)  
Antiguo 20/06/2011, 17:38
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

Muchas gracias por tu respuesta, me podrias explicar un poco mas como utilizo la función var_dump?


por tu tiempo, muchas gracias
  #4 (permalink)  
Antiguo 20/06/2011, 17:48
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

Ok, ya lei y utilice la función var_dump y las dos variables me tiran null, entonces el error esta en mi formulario, pero cual es? alguien puede guiarme?
  #5 (permalink)  
Antiguo 20/06/2011, 17:50
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

bueno entonces coloca aqui como tienes el formulario completo
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #6 (permalink)  
Antiguo 20/06/2011, 17:56
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

Gracias por tu tiempo, asi es como lo tengo, la funcion k me dijiste me arroja esto:

string(14) "$datos[\'ID\']" string(16) "$datos[\'movi\']"


ASI ES COMO TENGO EL FORMULARIO:

<form action="modificar.php" method="POST" name="form1" id="form1">
<table width="571" border="0">
<?php do { ?>
<tr>
<td><?php echo $row_datos['PAT']; ?></td>
<td><label><?php echo $row_datos['MAT']; ?></label></td>
<td><?php echo $row_datos['NOM']; ?></td>
<td><label>
<input type="checkbox" name="movi" value= "$datos['movi']" />
</label>
<input type="hidden" name="ID" value="$datos['ID']"/></td>
<td><?php echo $row_datos['SEC']; ?></td>
</tr>
<?php } while ($row_datos = mysql_fetch_assoc($datos));
?>
</table>
<p>
<label>
<input type="submit" name="hgty" id="hgty" value="ENVIAR" />

Y ASI EL DE MODIFICACION:
<?php require_once('Connections/movi.php');

$prueba = $_POST['ID'];
$nombre = $_POST['movi'];
var_dump($prueba, $nombre);
mysql_query("UPDATE pedido SET movi='$nombre' WHERE id='$prueba'");

?>


<BR>
<Center>
<A HREF="pedir.php"> Regresar </A>
</Center>

SALUDOS!!!!!!
  #7 (permalink)  
Antiguo 20/06/2011, 18:03
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

colocalo asi a ver

Código PHP:

<form action="modificar.php" method="POST" name="form1" id="form1">
<table width="571" border="0">
<?php do { ?>
<tr>
<td><?php echo $row_datos['PAT']; ?></td>
<td><label><?php echo $row_datos['MAT']; ?></label></td>
<td><?php echo $row_datos['NOM']; ?></td>
<td><label>
<input type="checkbox" name="movi" value= "<?php echo $datos['movi']; ?>" />
</label>
<input type="hidden" name="ID" value="<?php echo $datos['ID']; ?>"/></td>
<td><?php echo $row_datos['SEC']; ?></td>
</tr>
<?php } while ($row_datos mysql_fetch_assoc($datos));
?>
</table>
<p>
<label>
<input type="submit" name="hgty" id="hgty" value="ENVIAR" />
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #8 (permalink)  
Antiguo 20/06/2011, 18:09
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

te reitero mi agradecimiento

me tira esto:

string(2) "30" string(1) "0"

saludos!!!
  #9 (permalink)  
Antiguo 20/06/2011, 18:12
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

aja y el 30 y el 0 no pertenecen a movi y a ID respectivamente?

osea

movi = 30

ID=0
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #10 (permalink)  
Antiguo 20/06/2011, 18:17
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

nop,

movi es es campo check box y el id, obvio el indicativo, y no me actualiza no manda datos a la tabla :(
  #11 (permalink)  
Antiguo 20/06/2011, 18:23
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

pues fijate en esta linea

<input type="checkbox" name="movi" value= "<?php echo $datos['movi']; ?>" />

estas mostrando

<?php echo $datos['movi']; ?>

que contiene $datos['movi'];

yo creo que ese valor es el que te esta enviando al otro archivo

por otra parte en


<input type="hidden" name="ID" value="<?php echo $datos['ID']; ?>"/>

esta <?php echo $datos['ID']; ?>

que contiene $datos['ID']; ?

yo creo que o estas confundido tu o estoy confundido yo
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #12 (permalink)  
Antiguo 20/06/2011, 18:51
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

Ya cheque, el problema es k me esta tomando el mismo id para todos los datos, donde crees k pueda estar el error? son 30 registros que se visualizan y me toma el ultimo....
  #13 (permalink)  
Antiguo 20/06/2011, 19:01
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

pues haz asi aunque yo estoy adivinando porque no haz colocado el codigo completo

<form action="modificar.php" method="POST" name="form1" id="form1">
<table width="571" border="0">
<?php while ($row_datos = mysql_fetch_assoc($datos)) { ?>
<tr>
<td><?php echo $row_datos['PAT']; ?></td>
<td><label><?php echo $row_datos['MAT']; ?></label></td>
<td><?php echo $row_datos['NOM']; ?></td>
<td><label>
<input type="checkbox" name="movi" value= "<?php echo $row_datos['movi']; ?>" />
</label>
<input type="hidden" name="ID" value="<?php echo $row_datos['ID']; ?>"/></td>
<td><?php echo $row_datos['SEC']; ?></td>
</tr>
<?php } ?>
</table>
<p>
<label>
<input type="submit" name="hgty" id="hgty" value="ENVIAR" />
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #14 (permalink)  
Antiguo 20/06/2011, 19:08
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

gracias de nuevo,

te dejo el codigo completo, como veras soy nuevo en esto, y este es el codigo generado por dreamweaver, ya me estoy dando cuenta k lo mejor es empezar desde cero, en rojo esta lo k me haz ayudado a checar ya con la modificacion k me haz dado:

<?php require_once('Connections/movi.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "http://www.google.com";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "entra.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_Recordset1 = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_Recordset1 = $_SESSION['MM_Username'];
}
mysql_select_db($database_movi, $movi);
$query_Recordset1 = sprintf("SELECT * FROM ususb WHERE USUARIO = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $movi) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$colname_datos = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_datos = $_SESSION['MM_Username'];
}
mysql_select_db($database_movi, $movi);
$query_datos = sprintf("SELECT * FROM pedido WHERE usuario = %s", GetSQLValueString($colname_datos, "text"));
$datos = mysql_query($query_datos, $movi) or die(mysql_error());
$row_datos = mysql_fetch_assoc($datos);
$totalRows_datos = mysql_num_rows($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>Untitled Document</title>
</head>

<body>

<form action="modificar.php" method="POST" name="form1" id="form1">
<table width="571" border="0">
<?php while ($row_datos = mysql_fetch_assoc($datos)) { ?>
<tr>
<td><?php echo $row_datos['PAT']; ?></td>
<td><label><?php echo $row_datos['MAT']; ?></label></td>
<td><?php echo $row_datos['NOM']; ?></td>
<td><label>
<input type="checkbox" name="movi" value= "<?php echo $row_datos['movi']; ?>" />
</label>
<input type="hidden" name="ID" value="<?php echo $row_datos['ID']; ?>"/></td>
<td><?php echo $row_datos['SEC']; ?></td>
</tr>
<?php } ?>
</table>
<p>
<label>
<input type="submit" name="hgty" id="hgty" value="ENVIAR" />
</label>
<a href="<?php echo $logoutAction ?>">Cerrar</a></p>

</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($datos);
?>

Y EL DE ACTUALZIACION ES ESTE:
<?php require_once('Connections/movi.php');

$prueba = $_POST['ID'];
$nombre = $_POST['movi'];
var_dump($prueba, $nombre);
mysql_query("UPDATE pedido SET movi='$nombre' WHERE id='$prueba'");

?>


<BR>
<Center>
<A HREF="pedir.php"> Regresar </A>
</Center>

DE NUEVO, MUCHISIMAS GRACIAS!!!
  #15 (permalink)  
Antiguo 20/06/2011, 19:37
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

pues si ese codigo no lo haz hecho tu, te recomiendo 100% que empieces de cero asi sabes que es lo que estas haciendo y como funciona cada cosa.

pot otro lado no dijistes si te sirvio de algo lo que modifique
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #16 (permalink)  
Antiguo 20/06/2011, 19:43
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

hola!!!!

Desgraciadamente no, sigue sin vincular el id y no manda la actualziacion, disculpa tanta lata y gracias por apoyar y enseñar a los demas, k otra cosa podia modificar en este codigo?
  #17 (permalink)  
Antiguo 20/06/2011, 19:55
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

en vez de

<?php while ($row_datos = mysql_fetch_assoc($datos)) { ?>

usa

<?php while ($row_datos = mysql_fetch_array($datos)) { ?>

y elimina arriba

$row_datos = mysql_fetch_assoc($datos);
$totalRows_datos = mysql_num_rows($datos);



si no funciona haces un var_dump de $datos a ver que te muestra alli

sino pues me doy por hoy, xq ya tengo sueño
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #18 (permalink)  
Antiguo 20/06/2011, 20:08
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

Todavia no funciona, muchas gracias por tu tiempo me haz dado varias ideas para ver por donde esta mi error.... gracias
  #19 (permalink)  
Antiguo 21/06/2011, 07:26
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

ok volvi ya repotenciado

vamos a hacer como te dije desde 0 todo porque sino no aprendes y la idea es aprender, te estoy explicando asi porque yo lo que he aprendido de php principalmente es Gracias a este foro que me ha ayudado un monton, por eso te ayudo igual.

bueno a lo que vamos

muestra aqui exactamente como esta la estructura de tu base de datos y cual es el contenido que tiene por lo menos los 3 primeros ej:

id - cedula - nombre - cantidad
1 - 10210210 - jose luis - 20
2 - 11248563 - pedro perez - 15
3 - 1256358 - luis jose - 18

luego coloca como quieres que se muestre en el formulario con algunos datos igual y asi lo iremos haciendo de cero y vas a aprender si asi lo quieres
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #20 (permalink)  
Antiguo 21/06/2011, 10:06
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

ok. muchas gracias y k bueno k ya estas repuesto jajajaj

la tabla esta asi:
id - nom - pat - mat-movi
1-juan-perez-hernandez-0
2-victor-lopez-jimenez-0
3-juan carlos-hernandez-hernandez-0


El formulario se muestra asi:



lo k requiero es k con un solo submit me actualize el campo movi, que es el check box.

saludos!!!!!!
  #21 (permalink)  
Antiguo 21/06/2011, 12:08
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

aja y como quieres que actualice al campo movi porque segun la tabla todos estan en 0.

sera que si selecciono por ejemplo

juan perez y victor lopez estos dos cambien el movi de 0 a 1?
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #22 (permalink)  
Antiguo 22/06/2011, 18:43
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

exacto sensei, k cambie de 0 a 1
  #23 (permalink)  
Antiguo 22/06/2011, 19:23
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Actualizar multiples registros, no actualiza

empieza a probar asi a ver que sale de todo esto aunque hay muchas fallas hay aun te recomiendo que vayas leyendo la wiki de este foro para que sepas como va la cosa

Código PHP:
<?php
session_start
();

require_once(
'Connections/movi.php');


if (isset(
$_SESSION['MM_Username'])) {
$colname_datos $_SESSION['MM_Username'];
}
mysql_select_db($database_movi$movi);
$query_datos sprintf("SELECT * FROM pedido WHERE usuario = '$colname_datos'");
$datos mysql_query($query_datos$movi) or die(mysql_error());
$row_datos mysql_fetch_assoc($datos);
$totalRows_datos mysql_num_rows($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>Untitled Document</title>
</head>

<body>

<form action="modificar.php" method="POST" name="form1" id="form1">
<table width="571" border="0">
<?php while ($row_datos mysql_fetch_assoc($datos)) { ?>
<tr>
<td><?php echo $row_datos['PAT']; ?></td>
<td><label><?php echo $row_datos['MAT']; ?></label></td>
<td><?php echo $row_datos['NOM']; ?></td>
<td><label>
<input type="checkbox" name="movi" value= "<?php echo $row_datos['movi']; ?>" />
</label>
<input type="hidden" name="ID" value="<?php echo $row_datos['ID']; ?>"/></td>
<td><?php echo $row_datos['SEC']; ?></td>
</tr>
<?php ?>
</table>
<p>
<label>
<input type="submit" name="hgty" id="hgty" value="ENVIAR" /> </label>
<a href="<?php echo $logoutAction ?>">Cerrar</a></p>

</form>
</body>
</html>
<?php
mysql_free_result
($Recordset1);

mysql_free_result($datos);
?>
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O
  #24 (permalink)  
Antiguo 07/07/2011, 14:44
 
Fecha de Ingreso: octubre-2009
Mensajes: 38
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Actualizar multiples registros, no actualiza

gracias por su tiempo!!!!

asi quedo el codigo para el que lo necesite, saludos!!!

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$tot=$_POST['total'];
for($i=0;$i<=$tot;$i++)
{
$updateSQL = sprintf("UPDATE pedido SET movi=%s WHERE id=%s",
GetSQLValueString($_POST['movi'][$i], "int"),
GetSQLValueString($_POST['ID'][$i], "int"));


mysql_select_db($database_movi, $movi);
$Result1 = mysql_query($updateSQL, $movi) or die(mysql_error());

}



<?php $j=0; $totalregistros=0; do { ?>
<tr>
<td width="146"><div align="center"><span class="style2"></span><?php echo $row_Pedidos['CONSECUTIVO']; ?></div></td>
<td width="83"><span class="style3"><?php echo $row_Pedidos['PAT']; ?></span></td>
<td width="102"><span class="style3"><?php echo $row_Pedidos['MAT']; ?></span></td>
<td width="141"><span class="style3"><?php echo $row_Pedidos['NOM']; ?></span></td>
<td width="28" align="center"><input type="checkbox" name="movi[<?php echo $j; ?>]" value= "1" <?php if (!(strcmp($row_Pedidos['movi'],1)))
{echo "checked=\"checked\"";} ?> /><label for="movi"></label></td>

<input type="hidden" name="ID[<?php echo $j; ?>]" value="<?php echo $row_Pedidos['ID']; ?>"/>
<?php $j=$j+1;
$totalregistros=$totalregistros+1;

Etiquetas: multiples, registros
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 19:54.