Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/08/2013, 02:00
bathorz
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 11 años, 5 meses
Puntos: 29
Respuesta: formulario con checkbox

Para que sea parecido al tuyo, con while():
Código PHP:
Ver original
  1. <?php
  2. /** Prueba conexión BBDD y consulta (MySQL) **/
  3. $conn = conectadb('test'); // cambiar por tú conexión
  4. $sql = "SELECT * FROM dept RIGHT JOIN emp ON emp.deptid=dept.deptid;"; // cambiar por tú consulta
  5. $query = mysql_query($sql); // cambiar por odbc
  6. /** **/
  7.  
  8. ?>
  9. <style type="text/css">
  10. table { border: 1px solid #000;padding: 2px;
  11.     font: 10px;width: 433px;height: 48px;
  12. }
  13. td {border: 1px solid #999;}
  14. input {font: 10px;}
  15. </style>
  16.  
  17. <form action="" name="form" method="post">
  18.     <table>
  19.         <tr>
  20.             <th scope="col">
  21.                 <!--  -->
  22.                 <table>
  23.                     <thead>
  24.                         <tr>
  25.                             <th width="172">NOMBRE</th>
  26.                             <th width="101">MINISTERIO</th>
  27.                             <th width="20">DV</th>
  28.                             <th width="20">C.O</th>
  29.                             <th width="20">C.E</th>
  30.                             <th width="20">C.A</th>
  31.                             <th width="20">ALB</th>
  32.                             <th width="24">VIG</th>
  33.                     </thead>
  34.                     <tbody>
  35.                         <?php
  36.                        
  37.                         $i = 0;
  38.                         while( $row = mysql_fetch_array($query) ) {
  39.                            $nomb = $row['name'];
  40.                            $min = $row['dept'];
  41.                            
  42.                            echo '<tr>';
  43.                            echo"
  44.                            <td><input id='nombres' type='text' name='nombr[$i]' size=37 value='$nomb'readonly></td>
  45.                            <td><input id='min' type='text' name='min[$i]' value='$min' readonly></input></td>";
  46.                            /** ckeckbox **///DV C.O C.E C.A ALB VIG
  47.                            echo "
  48.                            <td><input type='checkbox' name='fila1[dv][$i]' value=1></td>
  49.                            <td><input type='checkbox' name='fila1[co][$i]' value=2></td>
  50.                            <td><input type='checkbox' name='fila1[ce][$i]' value=3></td>
  51.                            <td><input type='checkbox' name='fila1[ca][$i]' value=4></td>
  52.                            <td><input type='checkbox' name='fila1[alb][$i]' value=5></td>
  53.                            <td><input type='checkbox' name='fila1[vig][$i]' value=6></td>";
  54.                            echo '</tr>';
  55.                            
  56.                            $i++;
  57.                         }
  58.                         ?>
  59.                     </tbody>
  60.                 </table>
  61.             </th>
  62.         </tr>
  63.     </table>
  64.     <div class="demo">
  65.         <!--  -->
  66.         Fecha:
  67.         <?php
  68.         // fija el select en una opción
  69.         if (isset($_POST['fecha'])) {
  70.            echo "<input type='date' name='fecha' size='8' maxlength='10' value='".$_POST['fecha']."' />";
  71.         } else {
  72.            echo "<input type='date' name='fecha' size='8' maxlength='10' value='".date('Y-m-d')."' />";
  73.         }
  74.         ?>
  75.         <!--  -->
  76.         <input type="submit" name="nuevafecha" value="Enviar" />
  77.     </div>
  78. </form>
  79.  
  80. <?php
  81.  
  82. if(isset($_POST['nuevafecha'])) {
  83.    
  84.    echo $_POST['fecha'];
  85.    echo '<hr>';
  86.    print_r($_POST['nombr']);
  87.    echo '<hr>';
  88.    print_r($_POST['min']);
  89.    echo '<hr>';
  90.    print_r($_POST['fila1']);
  91.  
  92. }
  93. ?>