One possible way of doing this, (i think ?) , but it would need to be hand coded.
You would need to created a separate recordset for each year group, 1-4
the year 'title' could be dispayed using <optgroup label="Year 1"></optgroup> tags aroung the dynamic data.
use a different recordset within each set of optgroup tags.
eg
<select name="xxxx" multiple>
<optgroup label="Year 1">
<?php
do {
?>
<option value="<?php ...RECORDSET FOR YEAR 1></option>
<?php
} while ...
?>
</optgroup>
<optgroup label="Year 2">
<?php
do {
?>
<option value="<?php ...RECORDSET FOR YEAR 2></option>
<?php
} while ...
?>
</optgroup>
...
etc
</select>
...Another approach could be to use the parent/child relationship of dynamic dropdowns.
Use the first dropdown to choose the year, and the second (filtered) list for the relevant course.
This would, of course, depend on how a visitor selected their course