Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/04/2011, 14:19
Avatar de saseisa
saseisa
 
Fecha de Ingreso: agosto-2006
Mensajes: 329
Antigüedad: 18 años, 6 meses
Puntos: 9
problema con foreach

saludos a todos espero puedan ayudarme tengo problemas con el foreach
el problema que tengo es que no me captura el texto que meto en el input
mi tabla que se muestra en la pagina es como esta
recibo cancelar motivo
#recibo1 checkbox1 input1
#recibo2 checkbox2 input2
#recibo3 checkbox3 input3
#recibo4 checkbox4 input4
#recibo5 checkbox5 input5

por ejemplo
si selecciono el checkbox3 puedo poner texto en el input3 al momento que le doy al boton cancelar ese recibo se almacena y me lo marca como cancelado y el motivo por el cual se cancelo, con el checkbox no hay problema me lo almacena de forma correcta el problema es con el input no me almacena la informacion

codigo foreach
Código:
if(isset($_POST['button']))	{
  $arr=$_POST['cancela'];

foreach ($arr as $key => $value  ) { 

$mot=$_POST['motivo'][$key];   
$sql = "UPDATE comprobante SET cancelacion = 'CANCELADO', motivoCancelacion ='".$mot."' WHERE comprobante.idComprobante = '".$value."'";
  //mysql_query($sql, $factura) or die(mysql_error());  
}
y este es el codigo de donde tengo mi tabla que hace un ciclo para mostrar todos mis registros

Código:
<table width="80%" border="0" class="campos">
<tr>
    <th height="23" colspan="2" align="left">Comprobantes Impresos</th>
    <th width="113">Cancelar</th>
    <th width="218">Motivo</th>
    
  
  </tr>

<tr>
<?php do {	?>

	<th height="20" width="30" align="left" class=""><?php echo $row_fac['tipoFacturacion'];?></th>
	<th height="20" width="30" align="left" class=""><?php echo $row_fac['comprobante'] ;?></th>
	<th align="left" class=""><center>
	
<?php 
	if($row_fac['cancelacion']!="CANCELADO"){
		echo "<input type='checkbox' name='cancela[]' id='checkbox' value='".$row_fac['idComprobante'] ."'  >"; 
		echo $row_fac['idComprobante'];
			}
		else{echo $row_fac['cancelacion'];}
		
			?>
        </center>
   </th>
	<th align="left" class=""><?php 
	if($row_fac['cancelacion']!='CANCELADO'){
		echo "<input type='text' id='textbox' name='motivo[]' >";
		}else echo $row_fac['motivoCancelacion'];
		?></th>
  </tr>    
<?php } while ($row_fac = mysql_fetch_assoc($fac))?> 
</table>
espero puedan ayudarme