Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/01/2010, 15:08
warbandit69
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 16 años, 2 meses
Puntos: 19
Busqueda Problemas para capturar variables con bucle en php

Buenas Tardes foreros, gracias por leer mi post, voy directo al grano, tengo un formulario que genero mediante un bucle for y una base de datos unos campos dinamicos como veran aca (solo una parte):

Código:
<p>$consulta_materialesausar = "SELECT     *
FROM         RVMmaterialesrequeridos
WHERE     (correlativo = '".$correlativo."')";
$materialesausar = $db->Execute($consulta_materialesausar);<strong>Spare Part / Material / Equipment Authorization</strong></p>
    <table border="0">
      <tr>
        <th width="38" scope="col">Qty</th>
        <th width="306" scope="col">Spare Part / Material / Equipment</th>
        <th width="149" scope="col">Delivered Note No.</th>
        <th width="77" scope="col">OSE</th>
      </tr>
      <?php 
	  $i = 0;
	  if (!$materialesausar) 
			         print $db->ErrorMsg();
				else
					while (!$materialesausar->EOF) { 
					$i=$i+1;
					?>
      <tr>
        <td><span id="sprytextfield3">
          <label>
            <?php echo "<input type='text' name='cantidad[".$i."]' id='cantidad[".$i."]' class='cantidades' value='".$materialesausar->fields[2]."' readonly='readonly' disabled='disabled'/>"; ?>
          </label>
          <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
        <td><span id="sprytextfield4">
          <label>
            <?php echo "<input type='text' name='material[".$i."]' id='material[".$i."]' class='materiales' value='".$materialesausar->fields[3]."'  readonly='readonly' disabled='disabled'/>"; ?>
          </label>
          <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
        <td><span id="sprytextfield5">
          <label>
            <?php echo "<input type='text' name='notaentrega[".$i."]' id='notaentrega[".$i."]' class='notasentrega' value='".$materialesausar->fields[4]."'  readonly='readonly' disabled='disabled'/>"; ?>
          </label>
          <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
        <td><span id="spryselect7">
          <label>
            <?php echo "<select name='OSE[".$i."]' id='OSE[".$i."]'>
            <option selected='selected'>...</option>
            <option value='yes'>yes</option>
            <option value='no'>no</option>
            </select>"; ?>
            
          </label>
          <span class="selectRequiredMsg">Seleccione un elemento.</span></span><?php echo $i; ?></td>
      </tr>
      <?php 
	  $materialesausar->MoveNext(); 
	  }
	?>
    </table>
    <p><input name="objetosmateriales" type="hidden" value="<?php echo $i; ?>" />
Pero a la hora de capturar los valores en la otra pagina siempre me da unos errores de indice indefinido o me muestra un 0 unicamente, a continuacion les pongo el codigo aca:

Código:
<?php 
include("funciones.php");
include('Connections/radiomarina.php'); 
$marca = $_POST['marca'];
$nuevamarca = $_POST['newbrand'];
$equipo = $_POST['equipo'];
$nuevoequipo = $_POST['newcomponent'];
$serviciodado = $_POST['descripcion'];
$serial = $_POST['serial'];
$cant = $_POST['objetosmateriales'];
echo "Marca: ".$marca;
echo "<br>Nueva marca:".$nuevamarca;
echo "<br>Equipo: ".$equipo;
echo "<br>Nuevo Equipo: ".$nuevoequipo;
echo "<br>Servicio Dado: ".$serviciodado;
echo "<br>Serial: ".$serial;
echo "<br>Contador: ".$cant;
for($i = 1; $i = $cant; $i++ ) {
	$cantidad[$i] = $_POST['cantidad['.$i.']'];
	$material[$i] = $_POST['material['.$i.']'];
	$notaentrega[$i] = $_POST['notaentrega['.$i.']'];
	$OSE[$i] = $_POST['OSE['.$i.']'];
	echo "<br> Cantidad ".$i.": ".$cantidad[$i];
	echo "<br> Material ".$i.": ".$material[$i];
	echo "<br> Nota Entrega ".$i.": ".$notaentrega[$i];
	echo "<br> Se usó? ".$i.": ".$OSE[$i];
}
?>
Comento el for, y me captura todo bien , lo pongo y me da errores, si alguno da con cual es el problema se los agradezco en el alma, saludos.