Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] formulario con checkbox

Estas en el tema de formulario con checkbox en el foro de PHP en Foros del Web. Hola a todos, necesito su valiosa ayuda tengo una consulta y los resultados los presento en un formulario ahi agrego 6 checkbox para insertar unas ...
  #1 (permalink)  
Antiguo 26/08/2013, 10:20
 
Fecha de Ingreso: septiembre-2009
Mensajes: 11
Antigüedad: 14 años, 7 meses
Puntos: 0
formulario con checkbox

Hola a todos, necesito su valiosa ayuda tengo una consulta y los resultados los presento en un formulario ahi agrego 6 checkbox para insertar unas opciones como imprimo los resultados que se seleccionaron en el formulario adjunto el codigo

$sql = "select * from discipulo_sin_documento_nombre_corto a INNER JOIN dbo.VW_ULTIMOESTADO b
ON a.vc_iddiscipulo = b.VC_IDDISCIPULO
INNER JOIN dbo.VC_RELA_DISCIESTADO C
ON B.VC_IDRELADISCESTA = C.VC_IDRELADISCESTA
where VC_IDUNIDADOPERA=691 AND C.VC_IDRAZON IN (2,4,5,6,7,8,9,10,11,12) and VC_IDMINISTERIO='8' ";
$rs = odbc_exec( $conn, $sql );
if ( !$rs ) { exit( "Error en la consulta SQL" ); }?>
<form action="muestra.php" name="form" method="post">
<tr>

<th scope="col"><table width="433" height="48" style="font-size: 7pt" >
<thead>
<tr>
<th width="172">NOMBRE</th>
<th width="101">MINISTERIO</th>
<th width="20">DV</th>
<th width="20">C.O</th>
<th width="20">C.E</th>
<th width="20">C.A</th>
<th width="20">ALB</th>
<th width="24">VIG</th>
</thead>
<tbody>
<!--//$nom1=$row['VC_NOMBRE1'];$ape=$row['VC_APELLIDO1'];$nomb=$nom1.$ape;echo $nomb ;-->
<?php while( $row = odbc_fetch_array($rs) ) { ?>
<tr>
<?php $nomb=$row['VC_NOMBRE1'];
$min=$row['VC_DESC_MINISTERIO'];

echo"<input type='hidden' name='fila1[$nomb][0]' value='$nomb' />
<td><input id='nombres' type='text' name='nombr' value='$nomb'readonly style='font-size: 7pt'></td>
<td ><input id='min' type='text' name='min' value='$min' readonly style='font-size: 7pt'></input></td>
<td ><input type='checkbox' name='fila1[$nomb][1]' value=1></td>
<td ><input type='checkbox' name='fila1[$nomb][2]' value=2></td>
<td ><input type='checkbox' name='fila1[$nomb][3]' value=3></td>
<td ><input type='checkbox' name='fila1[$nomb][4]' value=4></td>
<td ><input type='checkbox' name='fila1[$nomb][5]' value=5></td>
<td ><input type='checkbox' name='fila1[$nomb][6]' value=6></td>

";?>





</tr>

<?php
}

?>



<div class="demo">
Selecciona fecha: <input id="datepicker" type="text" name="fecha">
<input type="submit" name="nuevafecha" value="Enviar"/>
</div>
</form>
  #2 (permalink)  
Antiguo 28/08/2013, 13:56
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 meses
Puntos: 29
Respuesta: formulario con checkbox

input type='date' de html5 aún no funciona bien en todos los navegadores, en Opera ok.
Código PHP:
Ver original
  1. <style type="text/css">
  2. table {
  3.     border: 1px solid #000; padding: 2px;
  4.     font: 10px; width: 433px; height: 48px;
  5. }
  6. td {border: 1px solid #999;}
  7. input {font: 10px;}
  8. </style>
  9.  
  10. <?php
  11. // nombre
  12. $nomb = array('n0','n1','n2','n3','n4','n5','n6','n7','n8','n9');
  13. // ministerio
  14. $min = array('m0','m1','m2','m3','m4','m5','m6','m7','m8','m9');
  15. //...
  16. $rs = array(1,2,3,4,5,6,7,8,9,10);
  17.  
  18. ?>
  19. <form action="" name="form" method="post">
  20.     <table>
  21.         <tr>
  22.             <th scope="col">
  23.                 <!--  -->
  24.                 <table>
  25.                     <thead>
  26.                         <tr>
  27.                             <th width="172">NOMBRE</th>
  28.                             <th width="101">MINISTERIO</th>
  29.                             <th width="20">DV</th>
  30.                             <th width="20">C.O</th>
  31.                             <th width="20">C.E</th>
  32.                             <th width="20">C.A</th>
  33.                             <th width="20">ALB</th>
  34.                             <th width="24">VIG</th>
  35.                    
  36.                     </thead>
  37.                     <tbody>
  38.                         <?php
  39.                         //while( $row = odbc_fetch_array($rs) ) {
  40.                         for ($i = 0; $i < count($rs); $i++) {
  41.  
  42.                            echo '<tr>';
  43.                            //$nomb=$row['VC_NOMBRE1'];
  44.                            //$min=$row['VC_DESC_MINISTERIO'];
  45.  
  46.                            echo"
  47.                            <td><input id='nombres' type='text' name='nombr[$i]' size=37 value='$nomb[$i]'readonly></td>
  48.                            <td><input id='min' type='text' name='min[$i]' value='$min[$i]' readonly></input></td>";
  49.                            /** ckeckbox **///DV C.O C.E C.A ALB VIG
  50.                            echo "
  51.                            <td><input type='checkbox' name='fila1[dv][$i]' value=1></td>
  52.                            <td><input type='checkbox' name='fila1[co][$i]' value=2></td>
  53.                            <td><input type='checkbox' name='fila1[ce][$i]' value=3></td>
  54.                            <td><input type='checkbox' name='fila1[ca][$i]' value=4></td>
  55.                            <td><input type='checkbox' name='fila1[alb][$i]' value=5></td>
  56.                            <td><input type='checkbox' name='fila1[vig][$i]' value=6></td>";
  57.                            echo '</tr>';
  58.                         }
  59.                         ?>
  60.                     </tbody>
  61.                 </table>
  62.             </th>
  63.         </tr>
  64.     </table>
  65.     <div class="demo">
  66.         <!--  -->
  67.         Fecha:
  68.         <?php
  69.         // fija el select en una opción
  70.         if (isset($_POST['fecha'])) {
  71.            echo "<input type='date' name='fecha' size='8' maxlength='10' value='".$_POST['fecha']."' />";
  72.         } else {
  73.            echo "<input type='date' name='fecha' size='8' maxlength='10' value='".date('Y-m-d')."' />";
  74.         }
  75.         ?>
  76.         <!--  -->
  77.         <input type="submit" name="nuevafecha" value="Enviar" />
  78.     </div>
  79.  
  80. </form>
  81.  
  82. <?php
  83. if(isset($_POST['nuevafecha'])) {
  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. ?>
  #3 (permalink)  
Antiguo 28/08/2013, 14:38
 
Fecha de Ingreso: septiembre-2009
Mensajes: 11
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: formulario con checkbox

Una duda que pena soy muy novato la consula con la que traigo los nombres es esta select * from Vista_mauricio_discipulo_sin_documento_nombre_cort o a INNER JOIN dbo.VW_ULTIMOESTADO b
ON a.vc_iddiscipulo = b.VC_IDDISCIPULO
INNER JOIN dbo.VC_RELA_DISCIESTADO C
ON B.VC_IDRELADISCESTA = C.VC_IDRELADISCESTA
where VC_IDUNIDADOPERA=691 AND C.VC_IDRAZON IN (2,4,5,6,7,8,9,10,11,12) and VC_IDMINISTERIO='$var'

como la plasmo en el codigo que me enviaste??? muchas graciass
  #4 (permalink)  
Antiguo 29/08/2013, 02:00
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 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. ?>
  #5 (permalink)  
Antiguo 30/08/2013, 07:42
 
Fecha de Ingreso: septiembre-2009
Mensajes: 11
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: formulario con checkbox

bathorz una ultima pregunta me podrias explicar como hago el insert a una tabla de la bd ya con los datos que me genera el formulario muchisimas graciasssss

Etiquetas: checkbox, formulario, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:05.