<td width="220" align="right">
       <select name="Depcategory"  dir="rtl" id="Depcategory" class="title">
                <option value="-1">chosse department</option>
                    echo "<option ".($DepSearch==$name?" selected=selected ":"")." value='$name'>$name</option>"; 


     <tr> <td> <strong>Teacher name</strong></td>
      <td width="200" align="right"><label for="TeacheSearch"></label><select name="TeacheSearch"  dir="rtl" id="TeacheSearch" class="title">
        <option value="-1">choose teacher</option>
                    $rs=$db->GetTeacher($_SESSION["Faculty"], $_SESSION["AdminWorkName"]);
                    echo "<option ".($Lname==$TeacheSearch?" selected='selected' ":"")." value='$Lname'>$Fname $WNO</option>";

I've this code and i need to fix it so when i change the value of the first select, the values at the second select will change according to the value i did choose at the first select..

for example, if i've choosed IT as department from the first select, at the second select teachers at IT depramtent will be displayed.

"the values at both select are delievred from the database.."


If you want to change the second select without a page refresh, then that's a Javascript issue. You'll need some AJAX code to retrieve the matching list, and a PHP script to provide that.

See this code snippet

i tried many things befor, and didn't work..
don't know how to fix it : (

Do you know how to program in JavaScript?

Ajax is the solution for your problem. If you don't know how to program in JavaScript and Ajax you need to use "two steps" to achive your goal. so you have to create two pages each with a form and each form will "submit". pass a hidden value from the form in the first page and "catch" it in the second page, test it "on the fly" and depending on its value (the hidden one passed from the first page) the menu in the second form takes the proper value.

Using jQuery is the simplest method.
Before providing code I will explain the concept that you require.

  1. Your main php page will contain two select drop downs

  2. The first select is populated using your GetAllDept query. The second select will be empty

  3. You will have a second php page which will call your GetTeacher query and will simply display the results inside <option> tags like your original code. This second page is run something like www.yourwebsite.com/getteachers?deptcategory=itdepartment

  4. When the value of the first select is changed, JavsScript/jQuery is used to "quietly" run the second php file (with the value of the first select) and then inject the displayed <options> into your second empty select.


Page 1.

Page 2.