title: My nested while loop is giving me only a single row from database whereas I have many records in database
body: <p>I want to create time table. Need to get subject names from database in check boxes and teachers name from database in select dropdown. I am using following code but it give me only single row. I don't know where I am doing mistake. </p>
  
  <pre><code>&lt;table width="100%"&gt;
     &lt;tr&gt;
       &lt;th&gt;Select Subject&lt;/th&gt;
       &lt;th&gt;Period Time&lt;/th&gt;
       &lt;th&gt;Teacher&lt;/th&gt;
     &lt;/tr&gt;
  &lt;?php 
     $query = mysqli_query($conn, "select * from subjects");
     while ($row = mysqli_fetch_array($query))
     {
     $subject_id = $row['subject_id'];
     $subject_name = $row['subject_name'];
     echo "&lt;tr&gt;
  
  
    &lt;td&gt;&lt;input type='checkbox' name='subject_id' value='$subject_id'&gt; $subject_name&lt;/td&gt;
      &lt;td&gt;
       &lt;div class='form-group'&gt;
       &lt;select name='class_time' class='form-control'&gt;
       &lt;option&gt;10:00&lt;/option&gt;
       &lt;option&gt;11:00&lt;/option&gt;
       &lt;option&gt;12:00&lt;/option&gt;
       &lt;option&gt;01:00&lt;/option&gt;
       &lt;/select&gt;
       &lt;/div&gt;
      &lt;/td&gt;
      &lt;td&gt;
     &lt;div class='form-group'&gt;
        &lt;select name='employee_id' class='form-control'&gt;";
        $query = mysqli_query($conn, "select * from employees where designation = 'Teacher' OR designation = 'Principal'");
        while ($row = mysqli_fetch_array($query)) 
        {
           $employee_id = $row['employee_id'];
           $employee_name = $row['employee_name'];
           echo "
           &lt;option&gt;$employee_name&lt;/option&gt;";
        }
           echo "&lt;/select&gt;&lt;/div&gt;
          &lt;/td&gt;
        &lt;/tr&gt;";
     }
  
    ?&gt;
  
  &lt;/table&gt;
  </code></pre>