title: Get value from one select & call values for another select from database
body: <p>I am developing a library project in PHP &amp; MYSQL in which I've created 3 tables in the DB namely: library_books, student_db &amp; issued_books.</p>
  
  <p>There's a page named issue.php which has been created for the admin to issue books to the students. The page has columns like Book_id, Book_title, Author, Class(student's class from I to XII), Student_name &amp; Student_id(text type disabled).</p>
  
  <p>I'm fetching all the book related details from the library_books database itself,</p>
  
  <p>what I want to achieve is when the user selects a value the Class field, the page should automatically get the list of the students' name enrolled in that class &amp; when Student_name is selected from this list, the Student_id should automatically get fetched into the Student_id field.</p>
  
  <p>Here's is the code, plz take a look</p>
  
  <pre><code>&lt;select required class='styled-select green semi-square' style='width: 15%; margin-left: 5px;' id='Class' name='st_Class'&gt;
      &lt;option selected='true' disabled='disabled' value=''&gt;Select Class&lt;/option&gt;
      &lt;option&gt;I&lt;/option&gt;
      &lt;option&gt;II&lt;/option&gt;
      &lt;option&gt;III&lt;/option&gt;
      &lt;option&gt;IV&lt;/option&gt;
      &lt;option&gt;V&lt;/option&gt;
      &lt;option&gt;VI&lt;/option&gt;
      &lt;option&gt;VII&lt;/option&gt;
      &lt;option&gt;VIII&lt;/option&gt;
      &lt;option&gt;IX&lt;/option&gt;
      &lt;option&gt;X&lt;/option&gt;
      &lt;option&gt;XI&lt;/option&gt;
      &lt;option&gt;XII&lt;/option&gt;
      &lt;/select&gt;   
      &lt;select required class="styled-select green semi-square" style="width: 15%" id="st_name" name="st_name"&gt;
  
      &lt;option selected='true' disabled='disabled' value=''&gt;Select Student&lt;/option&gt;
  &lt;?php
      $query2 = mysqli_query($conn,"SELECT Student_name FROM Student_db WHERE Class='st_Class'");
  while($row1 = mysqli_fetch_array($query2,MYSQLI_NUM))
  {
      $st_name = $row1[6];
      $st_id = $row1[5];
  }
  ?&gt;
      &lt;option&gt;&lt;?php echo(isset($_POST['st_name'])&amp;&amp;($_POST['st_name']=='1'));?&gt;&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type="text" id="st_id" value="&lt;?php echo $st_id?&gt;" name="st_id" disabled/&gt;
  </code></pre>