$sql="select * from subject where department = '".$_SESSION["department"]."'";
$dbquery=mysql_db_query("timetable",$sql);
while($result=mysql_fetch_array($dbquery)){
if($subjectname_timetable == $result[subj_name]){
?>
<?
$connection=mysql_connect("localhost","root","root") or die("เชื่อมต่อฐานข้อมูลไม่ได้");
mysql_query("SET NAMES utf8");
mysql_select_db("timetable") or die("ไม่สามารถเลือกฐานข้อมูลได้");
$sql="select * from subject where department = '".$_SESSION["department"]."'";
$dbquery=mysql_db_query("timetable",$sql);
while($result=mysql_fetch_array($dbquery)){
if($subjectname_timetable == $result[subj_name]){
?>
<option value="<?=$result[subj_code];?>" selected="selected"><?=$result[subj_name];?></option>
<?
}else{?>
<option value="<?=$result[subj_code];?>"><?=$result[subj_name];?></option>