Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/10/2014, 06:18
Avatar de the_web_saint
the_web_saint
 
Fecha de Ingreso: mayo-2008
Ubicación: localhost/tierra/america/panama
Mensajes: 1.229
Antigüedad: 15 años, 11 meses
Puntos: 43
Respuesta: Rellenar los select que se encuentran dentro de un bucle for

En realidad solo basta hacer esto:
Código PHP:
Ver original
  1. <html>
  2.     <head>
  3.         <meta charset="UTF-8">
  4.         <title></title>
  5.     </head>
  6.     <body>
  7.         <?php
  8.         if(isset($_REQUEST['nota'])){
  9.             $nota=$_REQUEST['nota'];
  10.         }
  11.         else{
  12.             $nota="";
  13.         }
  14.         $con=  mysqli_connect("127.0.0.1", "root", "root");
  15.         mysqli_select_db($con, "prueba");
  16.          
  17.         ?>
  18.         <h2>NOTA DE LOS ALUMNOS</h2>
  19.          
  20.             <form action="" name="">
  21.                 <?php
  22.                 for($i=0;$i<$nota;$i++){ ?>
  23.                 <table>
  24.                     <tbody>
  25.                         <tr>
  26.                             <td>Nombre<br>
  27.                                 <input name="NOM_ALUMNO[]" type="text"></td>
  28.                             <td>COD_ALUM<br>
  29.                                 <input name="COD_ALUMNO[]" type="text" size="9"></td>
  30.                         </tr>
  31.                         <tr>
  32.                             <td>
  33.                                 <select name="LISTA_CURSOS[]">
  34.                                     <?php
  35.                                    $consulta=  mysqli_query($con, "select * from curso");
  36.                                    while($fila=  mysqli_fetch_array($consulta)){ ?>
  37.                                     <option value="<?php echo $fila['COD_CURSO']; ?>"><?php echo $fila['COD_CURSO']; ?></option>
  38.                                     <?php } ?>
  39.                                 </select>
  40.                                 <br>
  41.                             </td>
  42.                             <td><br>
  43.                             </td>
  44.                         </tr>
  45.                     </tbody>
  46.                 </table>
  47.                 <?php }
  48.                 ?>
  49.             </form>
  50.         <p><br>
  51.         </p>
  52.     </body>
  53. </html>

Puedes investigar un poco sobre el tema de como manejar los arreglos de valores pasados por formularios.

Saludos,
__________________
..::The Saint::..
El pesimista se queja del viento; el optimista espera que cambie; el realista ajusta las velas.