PDA

Ver la Versión Completa : ¿Actualizar varios registros a la vez? Ayuda... por favor


georkis
29-04-2008, 21:56:45
<form id="form1" name="form1" method="post" action="act_url_jcce.php">
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="22%">&nbsp;</td>
<td width="60%">&nbsp;</td>
<td width="10%">&nbsp;</td>
<td width="8%">&nbsp;</td>
</tr>
<?php do { ?><tr>
<td><input name="munic[<?php echo $row_jcce['munic']; ?>]" type="text" id="munic" value="<?php echo $row_jcce['munic']; ?>" size="20" /></td>
<td><input name="reg[<?php echo $row_jcce['id']; ?>]" type="hidden" id="id" / value="reg[<?php echo $row_jcce['id']; ?>]">
<input name="url[<?php echo $row_jcce['url']; ?>]" type="text" id="url" value="<?php echo $row_jcce['url']; ?>" size="50" /></td>
<td><p>.</p>
<p>
<input name="sitio" type="hidden" id="sitio" value="<?php echo $row_jcce['sitio']; ?>" />
</p></td>
<td>&nbsp;</td>
</tr>
<?php } while ($row_jcce = mysql_fetch_assoc($jcce)); ?>
<tr>
<td><input name="act_jcce" type="submit" id="act_jcce" value="Actualizar" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>

<!-- es esta es la página que procesa los datos -->

<?php require_once('../../Connections/nue.php'); ?>
<?php

/// esto es una array que capta la variable del formulario
if(!empty($_POST['reg'])){
$registros= array_keys($_POST['reg']);
$registros= implode("','", $registros);
$registros= "'" . $registros . "'";

$mun= array_keys($_POST['munic']);
$mun= implode("','", $mun);
$mun= "'" . $mun . "'";

$url= array_keys($_POST['url']);
$url= implode("','", $url);
$url= "'" . $url . "'";



$updateSQL = "UPDATE url_jcce SET munic=$mun, url=$url WHERE id IN ($registros)";


mysql_select_db($database_nue, $nue);
$Result1 = mysql_query($updateSQL, $nue) or die(mysql_error());
echo "se ha modificado los datos satisfactoriamente";
// no me sale la función header("Location: link.php?cmg");
}

?>

roman
29-04-2008, 22:06:23
Si quieres ayuda, por favor tómate el tiempo y la molestia de describir tu problema, cuál es la falla y cuál el resultado que quisieras. No esperes que con sólo ponernos el código vamos a entender de qué se trata.

// Saludos

georkis
29-04-2008, 22:56:38
la idea es la siguiente... tan solo, quiero actualizar todos los resgistros de direcciones de sitio web a la vez y la tabla es la siguiente.

CREATE TABLE `url_prov` (
`id_url` int(4) NOT NULL auto_increment,
`prov` char(35) default NULL,
`url` char(120) default NULL,
`tipo` enum('sitio','correo') default 'sitio',
PRIMARY KEY (`id_url`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

Lo que quiero que se actualice es el campo url...

Espero que me ayudes...