Hola a todos
Les cuento. Estoy tratando de cargar un combobox haciendo una consulta, pero esa consulta depende de la seleccion de otro combobox de mas arriba, pero no me resulta.
Código: php

- Al seleccionar una carrera debe cargar en el combobox alumnos esos alumnos. Ayuda plz
Saludos
Les cuento. Estoy tratando de cargar un combobox haciendo una consulta, pero esa consulta depende de la seleccion de otro combobox de mas arriba, pero no me resulta.
<tbody>
<tr> <td> Hora inicio </td> <td> <input type="text" maxlength="5" name="hora_inicio" id="hora_inicio" /> </td> </tr>
<tr> <td> Hora Fin </td> <td> <input type="text" maxlength="5" name="hora_fin" id="hora_fin" /> </td> </tr>
<tr> <td> dia </td> <td> <input type="text" maxlength="9" name="dia" id="dia" /> </td> </tr>
<tr> <td> Carreras </td> <td>
<select name="carrera" size="1">
<?php
$sql = "SELECT DISTINCT carrera FROM alumno";
$stmt = $bd->ejecutar($sql);
if ($stmt > 0) {
while ($rowEmp = $bd->obtener_fila($stmt,0)){
$carrera = $rowEmp['carrera'];
?>
<option value="<?php echo $carrera ?>"> <?php echo $rowEmp['carrera']?> </option>
<?php } }?>
</select></td> </tr>
<tr> <td> Asignatura </td> <td>
<select name="asignatura" size="1">
<?php
$sql = "SELECT idasignatura,nombre FROM asignatura";
$stmt = $bd->ejecutar($sql);
if ($stmt > 0) {
while ($rowEmp = $bd->obtener_fila($stmt,0)){
?>
<option value="<?php echo $rowEmp['idasignatura'] ?>"> <?php echo $rowEmp['nombre']?> </option>
<?php } }?>
</select></td> </tr>
<tr> <td> Alumno </td> <td>
<select name="alumno" size="1">
<?php // aqui debo hacer la consulta dependiendo del otro combobox
$sql = "SELECT rut,nombres,apellido_p,apellido_m FROM alumno WHERE carrera = $carrera";
$stmt = $bd->ejecutar($sql);
if ($stmt > 0) {
while ($rowEmp = $bd->obtener_fila($stmt,0)){
?>
<option value="<?php echo $rowEmp['rut'] ?>"> <?php echo $rowEmp['nombres'] . " " . $rowEmp['apellido_p']?> </option>
<?php } }?>
</select></td> </tr>
</tbody>

- Al seleccionar una carrera debe cargar en el combobox alumnos esos alumnos. Ayuda plz
Saludos





