<?php session_start(); include "datos.php"; include "funciones.php"; $id = $_POST["id"]; try { $bd = new PDO($dsnw, $userw, $passw, $optPDO); $sql = "SELECT \r\n\t\tfamilias.id_familia,\r\n\t\tfamilias.nombre\r\n\tFROM familias\r\n\tINNER JOIN afs ON afs.id_familia=familias.id_familia\r\n\tWHERE familias.id_empresa=" . varEmpresa() . " AND afs.id_area={$id}\r\n\tGROUP BY familias.id_familia;"; $res = $bd->query($sql); echo '<option selected="selected" disabled="disabled">Elige familia</option>'; foreach ($res->fetchAll(PDO::FETCH_ASSOC) as $v) { echo '<option value="' . $v["id_familia"] . '">' . $v["nombre"] . '</option>'; } } catch (PDOException $err) { echo "<option>Error: " . $err->getMessage(); }
<?php session_start(); include "datos.php"; include "funciones.php"; $id = $_POST["id"]; try { $bd = new PDO($dsnw, $userw, $passw, $optPDO); $sql = "SELECT \r\n\t\tsubfamilias.id_subfamilia,\r\n\t\tsubfamilias.nombre\r\n\tFROM subfamilias\r\n\tINNER JOIN afs ON afs.id_subfamilia=subfamilias.id_subfamilia\r\n\tWHERE subfamilias.id_empresa=" . varEmpresa() . " AND afs.id_familia={$id}\r\n\tGROUP BY subfamilias.id_subfamilia;"; $res = $bd->query($sql); echo '<option selected="selected" disabled="disabled">Elige subfamilia</option>'; foreach ($res->fetchAll(PDO::FETCH_ASSOC) as $v) { echo '<option value="' . $v["id_subfamilia"] . '">' . $v["nombre"] . '</option>'; } } catch (PDOException $err) { echo "<option>Error: " . $err->getMessage(); }
<div class="inset_form"> <h3 class="titulo_form">Pertenece a:</h3> <div class="campo_form"> <label class="">Área:</label> <select class="id_area" name="id_area"><?php try { $bd = new PDO($dsnw, $userw, $passw, $optPDO); $res = $bd->query("SELECT * FROM areas WHERE id_empresa=" . varEmpresa() . ";"); echo '<option selected="selected" disabled="disabled">Elige área</option>'; foreach ($res->fetchAll(PDO::FETCH_ASSOC) as $v) { echo '<option value="' . $v["id_area"] . '">' . $v["nombre"] . '</option>'; } } catch (PDOException $err) { echo "<option>Error: " . $err->getCode() . " SELECT * FROM areas WHERE id_empresa=" . varEmpresa() . ";" . "</option>"; } ?> </select> </div> <div class="campo_form"> <label class="">Familia</label> <select class="id_familia" name="id_familia"><?php //echo '<option selected="selected" disabled="disabled">Elige área</option>'; ?> </select> </div> <div class="campo_form"> <label class="">Sub familia</label> <select class="id_subfamilia" name="id_subfamilia"><?php //echo '<option selected="selected" disabled="disabled">Elige área</option>'; ?> </select>