Hi, I have a form with dropdowns which are populated from a mysql database. I need them to work so that the selection in the first dropdown narrows the mysql query and therefore the results in the second drop down, I of course need this to happen when different options are selected in the first drop down. Here is my code so far:
<label>Department</label><br />
<select name="department" size="1">
<?php
$department_query = $local_mysqli->query("SELECT id, name FROM department");
while ($department_array = mysqli_fetch_array($department_query)){
$department_id = $department_array['id'];
$department_name = $department_array['name'];
echo "<option value=\"$department_id\">$department_name</option>\n";
};
?>
</select>
<br />
<label>Position</label><br />
<select name="position" size="1">
<?php
$position_query = $local_mysqli->query("SELECT id, title FROM positions WHERE assigned=0, department=$department_id");
while ($position_array = mysqli_fetch_array($position_query)){
$position_id = $position_array['id'];
$position_title = $position_array['title'];
echo "<option value=\"$position_id\">$position_title</option>\n";
};
?>
</select>