PHP和Ajax中的从属组合框

I need help with my code. I want to select values from the database based on the first combo box selection. The first combo box has subject ID, which I want to use in my SQL to find the value of the second combo box.

<form class ="form_group" id="form1" enctype="multipart/form-data" method="POST" action="uploadstudent.php"> 
  StudentID:<br>
  <input type="text" name="StudentID" value="<?php echo $_SESSION['login_user'];?>"readonly>
  <br><br>
  Subject ID:<br>
  <select id="soflow" name="SubjectID" onChange="getState(this.value);">
    <option>
     <?php
     mysql_connect("localhost", "id503120_course", "12345678");
     mysql_select_db('id503120_course_db');
      $StudentID=$_SESSION['login_user'];
      $Course = mysql_query("SELECT course FROM student WHERE StudentID = '".$StudentID."'");
$result = mysql_fetch_assoc($Course);
$newcourse = implode($result);
      $query=mysql_query("SELECT SubjectID FROM subjects WHERE Course= '".$newcourse."' AND SubStatus = 'Y'");            
        if(!$numrows=mysql_num_rows($query)==0)
        {
            while($row=mysql_fetch_assoc($query))
            { ?>
                <option value="<?php echo $row['SubjectID']; ?>">
                <?php echo $row['SubjectID']; ?>
                </option>
          <?php }
        }
        else{
          echo "No submissions are currently open for you";
        }

      ?>
  </select>
<script>
function getState(val) {
    $.ajax({
    type: "POST",
    url: "submission.php",
    data:'SubjectID='+val,
    success: function(data){
        $('#soflow2').html(data);
    }
  });
}
</script>


    Assign number:  <br><select id="soflow2" name="AssessmentNum">
    <option>
    <?php
     mysql_connect("localhost", "id503120_course", "12345678");
     mysql_select_db('id503120_course_db');

 if(!empty($_POST["SubjectID"])) {
  $query ="SELECT AssignNum FROM subjects WHERE SubjectID = '".$_POST['SubjectID']."'";
                while($row=mysql_fetch_assoc($query))
            { ?>
                <option value="<?php echo $row['AssignNum']; ?>">
                <?php echo $row['AssignNum']; ?>
                </option>
          <?php }
 }
      ?>

Here in assign number, I am not able to view any information at all. Please help me.

The problem is in the parameter SubjectID in the ajax request. try this:

function getState(val) {
    $.ajax({
    type: "POST",
    url: "submission.php",
    data:{'SubjectID' :val},
    success: function(data){
        $('#soflow2').html(data);
    }
  });
}