Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/04/2011, 05:52
PxHx
 
Fecha de Ingreso: noviembre-2010
Ubicación: Capital Federal, Buenos Aires
Mensajes: 60
Antigüedad: 14 años, 3 meses
Puntos: 0
Update multiple no actualiza

Estimados ¿Como Estan? Les cuento que estoy tratando de armar un script para actualizar varios campos de varias filas a la vez, el problema es que no actualiza los campos, al hacer click en submit vuelve a la pantalla sin modificaciones ¿Me podrán ayudar? Gracias


Código PHP:
<?php 
$host
="localhost"
$username="root"
$password=""
$db_name="sanandre_sap"


mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 

$sql="select *
from sistema
where `destacado` = 'Si'
and `estado` = 'Activo'"

$result=mysql_query($sql); 


$count=mysql_num_rows($result); 
?> 
<table width="500" border="0" cellspacing="1" cellpadding="0"> 
<form name="form1" method="post" action=""> 
<tr> 
<td> 
<table width="500" border="0" cellspacing="1" cellpadding="0"> 


<tr> 
<td align="center"><strong>Id</strong></td> 
<td align="center"><strong>x</strong></td> 
<td align="center"><strong>x</strong></td> 
<td align="center"><strong>x</strong></td>  
</tr> 
<?php 
while($rows=mysql_fetch_array($result)){ 
?> 
<tr> 
<td align="center"><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td> 
<td align="center"><input name="tipoinmueble[]" type="text" id="tipoinmueble" value="<?php echo $rows['tipoinmueble']; ?>"></td> 
<td align="center"><input name="tipodeoperacion[]" type="text" id="tipodeoperacion" value="<?php echo $rows['tipodeoperacion']; ?>"></td> 
<td align="center"><input name="barrio[]" type="text" id="barrio" value="<?php echo $rows['barrio']; ?>"></td> 
</td> 
</tr> 
<?php 

?> 
<tr> 
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> 
</tr> 
</table> 
</td> 
</tr> 
</form> 
</table> 
<?php  
if($_POST){

$totalRecords count($_POST); 
for(
$i=0;$i<$totalRecords ;$i++){ 

  
$sql1="UPDATE prueba SET tipoinmueble='".$_POST['tipoinmueble'][$i]."', tipodeoperacion='".$_POST['tipodeoperacion'][$i]."', barrio='".$_POST['barrio'][$i]."' WHERE id='".$id[$i]."'"
  
$result1=mysql_query($sql1); 
  } 


if(
$result1){ 
header("location:update.php"); 

mysql_close(); 
?>