title: Creating an HTML form basing on information extracted from an SQL database using while loop
body: <p>I am trying to create a form, basing on information picked from the database using a while loop. I need some guidance on how to go about this. When form is supposed to return multiple values (of students) and then a text field for inputting marks is assigned to the students returned, which should allow the user input the marks and then submit the form. </p>
  
  <p>Here is the code i have sofar</p>
  
  <pre><code>        &lt;form method="post"&gt;
          &lt;?php
            //picking student details
              $sql = mysql_query("SELECT * 
              FROM student, class, subject, assesment
              WHERE 
              student.class_id = '$assesment_class' 
              AND subject.idsubject = '$assesment_subject' 
              AND subject.subject_option = 'Major' 
              AND class.idclass = student.class_id
              AND class.idclass = subject.class_id
              AND assesment.subject_idsubject = subject.idsubject
              AND assesment.idassesment = '$ass'
              ");
                  $Count = mysql_num_rows($sql); //counting the the selected rows
  
                  if($Count &gt; 0){
  
                      while($row = mysql_fetch_array($sql)){
                      //picking database values
                      $student_id = $row["idstudent"];
                      $student_names = $row["student_names"];
  
                               //Query for checking results 
                                  $sql1 = mysql_query("SELECT * 
                                  FROM result, student_has_result, grade, student, assesment
                                  WHERE 
                                  student_has_result.student_id = '$student_id' 
                                  AND student_has_result.student_class_id = '$assesment_class' 
                                  AND student_has_result.assesment_id = '$ass' 
                                  AND student_has_result.result_id = result.idresult 
                                  AND result.grade_idgrade = grade.idgrade 
                                  AND student_has_result.assesment_id = assesment.idassesment 
                                  AND student_has_result.student_id = student.idstudent 
                                  AND student_has_result.result_id = result.idresult");
  
                                      $Count1 = mysql_num_rows($sql1); //counting the the selected rows
  
                                      if($Count1 &gt; 0){
                                          while($row = mysql_fetch_array($sql1)){
                                          //picking database values
                                          $mark = $row["mark"];
  
                                          //echo $mark; 
  
                                         }
                                      }else{
                                      $mark = "";
                                      }
  
                              ?&gt;      
  
                      &lt;tr&gt;
                       &lt;td&gt;&lt;?php echo $student_names; ?&gt;&lt;/td&gt;
  
                       &lt;td&gt;
                       &lt;input type="text" name="result" placeholder="&lt;?php echo $mark; ?&gt;"/&gt;
                       &lt;input type="hidden" name="student" value="&lt;?php echo $student_id; ?&gt;"/&gt;
                       &lt;input type="hidden" name="assesment" value="&lt;?php echo $ass; ?&gt;"/&gt;
                       &lt;/td&gt;
                      &lt;/tr&gt;
  
  
  
                      &lt;?php
                     }
                     ?&gt;
  
                      &lt;tr&gt;
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;button name="submit-results-button" type="submit" class="btn btn-success"&gt;-Submit Students Results Now-&lt;/button&gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>Any guidance will be highly appreciated.</p>