HTML中的表单和表单字段

I'm trying to make an automated absent management software for an academic institute. Being just a rookie i'm stuck at this point. I want the name of a teacher to not appear in the drop down lists against the remaining absent teachers for a particular period once he has been selected to substitute for a staff. This I want without hitting the final submit button in the end. I.e.- before actually storing into actual database.

The name Sujata Das shouldn't appear for Aditi Bhatia for period 3.

Image

Here's the code that I have used to populate the drop down lists..

       //------------------FOLLOWING MODULE LISTS DOWN THE NAME OF THE TEACHERS WHO ARE PRESENT AS WELL AS FREE FOR A PARTICULAR PERIOD OF THE ABSENT TEACHER----------------


$a=1;
$r5 = mysql_query("SELECT class FROM timetable WHERE empno={$row['empno']} and period=$a");
while($r6=mysql_fetch_array($r5,MYSQL_ASSOC))
{

    if($r6['class']!=0)
    {   
        echo "<td>";

        echo "<select name='name' id='name'>";
         echo "<option selected disabled hidden value=''></option>";

        $r5=mysql_query("select m.name,m.empno,t.empno, t.attend,t.date,s.empno,s.period,s.class from master m,tattend t,timetable s where (m.empno=t.empno and m.empno=s.empno and t.attend=0 and t.date='$d' and s.period=$a and s.class=0)");
        while($r6=mysql_fetch_array($r5,MYSQL_ASSOC))
        echo "<option value='" . $r6['name'] . "'>" . $r6['name'] . "</option>";
        echo "</select>";
        echo "</td>";
    }
    else echo "<td></td>";

++$a;
$r5 =mysql_query("SELECT class FROM timetable WHERE empno={$row['empno']} and period=$a");
}
echo "</tr><tr></tr>";