Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/08/2013, 13:34
bathorz
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 meses
Puntos: 29
Respuesta: Resultado usando foreach

Prueba este script
Código PHP:
Ver original
  1. <?php
  2. $row = array('10','11','12','13','14');
  3. ?>
  4. <form id="ver_sorteos" name="" method="post" action="">
  5.     <?php
  6.     echo '<table border=1>';
  7.     echo '<tr><th>Num</th><th>P</th><th>Cant</th></tr>';
  8.     for ($i = 0,$can=1; $i < count($row); $i++,$can++) {
  9.        echo "<tr>
  10.        <th>".$row[$i]."</th>
  11.        <td><input type=checkbox title=Pedir value=".$row[$i]." name='numero[$i]' />
  12.        <td><input type=text size='5' name=cantidad[$i] value='' /></td>
  13.        </tr>\n";
  14.     }
  15.     echo '</table>';
  16.     ?>
  17.     <input type="submit" name="enviar">
  18. </form>
  19.  
  20. <?php
  21.  
  22. if ($_POST['enviar']) {
  23.  
  24.    if (array_sum($_POST['cantidad']) == 0) {
  25.       echo 'No hay cantidad';
  26.       exit;
  27.    }
  28.    if (empty($_POST['numero'])) {
  29.       echo 'No hay pedidos';
  30.       exit;
  31.    }
  32.  
  33.    echo '<table border=1>';
  34.    echo '<tr><th>Num</th><th>Cant</th></tr>';
  35.  
  36.    for ($e = 0; $e < count($_POST['cantidad']); $e++) {
  37.       if ($_POST['cantidad'][$e]) {
  38.          echo "<tr>
  39.         <th>".$_POST['numero'][$e]."</th>
  40.         <td>".$_POST['cantidad'][$e]."</td>
  41.         </tr>";
  42.       }
  43.    }
  44.    echo '</table>';
  45. }
  46.  
  47. ?>