After considerable time bashing the code around I have found a solution, this may be ugly and there may be more efficient ways of doing this however here is the final piece of code that works for me
//editing departments using department id//
$select_o_dept_names = "SELECT *
FROM `departments`
WHERE department_id = ".$main_report['department']."";
$run_select_o_dept = mysql_query($select_o_dept_names,$link);
$dept_o_data=mysql_fetch_array($run_select_o_dept);
$select_dept_names = "SELECT *
FROM `departments`
WHERE status = 'active'
ORDER BY department_name ASC ";
$run_select_dept = mysql_query($select_dept_names,$link);
print("<table id='edit_table_within'>Department:</td><td><select name=\"department\">
<option value=\"".$main_report['department']."\">".$dept_o_data['department_name']."</option>");
while($dept_data=mysql_fetch_array($run_select_dept))
{
print("<option value=\"".$dept_data['department_id']."\">".$dept_data['department_name']."</option>");
}print("
</select></td></tr>");