The best way to do this is to use ajax. This is a very simple way to do it, using jQuery :
index.php
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!-- here come the following of your page... -->
</head>
<body>
<!-- Your body... -->
<select name="subject_id" id="subject_id">
<?php
// Saying that $list is the list of users from mysql
foreach ($list as $user) {
?>
<option value="<?php echo $user; ?>"><?php echo $user; ?></option>
<?php
}
?>
</select>
<select name="sub_select" id="sub_select">
</select>
<script type="text/javascript">
$(document).ready(function () {
$('#subject_id').change(function () {
$('#sub_select').load('subselect.php?id=' + $('#subject_id').val());
}
}
</script>
</body>
</html>
And the file used to retrieve datas (note : no html, head or body tags here) :
subselect.php
<?php
$id = (int) $_GET['id'];
// This is where you do the where subject_id="selected drop down subject_id" sql query
$list = my_function_to_get_datas($id);
foreach ($list as $option) {
?>
<option value="<?php echo $option; ?>"><?php echo $option; ?></option>
<?
}
?>
I didn't test it but it's the idea.
jQueryorExtJSframeworks, they can be useful for you - k102