<?php /*=== function: build_depts: void -> void purpose: expects nothing, and outputs a form with a dynamically built drop-down of current departments and a submit button * if it cannot connect to the database, hum_conn_sess should cause it to complain and then exit, including destroying the current session and including a link to hopefully-conveniently start over uses: function hum_conn_sess by: Sharon Tuttle last modified: 2026-04-22 ===*/ function build_depts() { ?> <form id="depts_form" method="post" action="<?= htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES) ?>"> <fieldset> <legend> Which Department? </legend> <?php // try to query department names and numbers $conn = hum_conn_sess(); $dept_stmt = oci_parse($conn, "select dept_num, dept_name from dept order by dept_name"); oci_execute($dept_stmt, OCI_DEFAULT); // build a select/drop-down form widget of departments ?> <select name="dept"> <?php while (oci_fetch($dept_stmt)) { $next_dept_num = oci_result($dept_stmt, "DEPT_NUM"); $next_dept_name = oci_result($dept_stmt, "DEPT_NAME"); ?> <option value="<?= $next_dept_num ?>"> <?= $next_dept_name ?> </option> <?php } ?> </select> <?php oci_free_statement($dept_stmt); oci_close($conn); ?> </fieldset> <div class="submit_part"> <input type="submit" value="Submit" /> </div> </form> <?php } ?>