title: Inserting multiple rows from a php form into the database
body: <p>my form as the following table (of textfeild). I am feeding the values into these textfeild. How can i enter these values into my database? plz help.
  <img src="https://i.stack.imgur.com/PRPEL.jpg" alt="enter image description here"></p>
  
  <p>code of the form:- </p>
  
  <pre><code>    $rows=$_POST["rows"];       
            echo "
          &lt;table align=\"center\" border=\"1\" width=\"70%\"&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;b&gt;Roll No.&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Full Name&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Unit_test&lt;/b&gt;       &lt;/td&gt;&lt;td&gt;&lt;b&gt;Prelims&lt;/b&gt;&lt;/td&gt; 
          &lt;td&gt;&lt;b&gt;Attendance&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;File&lt;/b&gt;&lt;/td&gt; 
          &lt;/tr&gt;";
  
      for($n=0;$n&lt;$rows;$n++)
      { 
      echo "&lt;tr&gt;
      &lt;td&gt;&lt;input type=\"text\" name=\"roll\" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=\"text\"                 name=\"name\" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=\"text\" name=\"unit_test\" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type=\"text\" name=\"prelims\" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=\"text\"  name=\"attendance\" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=\"text\" name=\"file\" /&gt;&lt;/td&gt;
      &lt;/tr&gt;";
      }
       echo "&lt;/table&gt;";
       echo "&lt;form action=\"feed2.php\" method=\"post\"&gt;
      &lt;br&gt;
       &lt;input type=\"submit\" name=\"\" value=\"Submit\" /&gt;
     &lt;/form&gt;";
  </code></pre>
  
  <p>code used for inserting into db:-</p>
  
  <pre><code>for($n=0;$n&lt;3;$n++)
  {
    if(isset($_POST['roll']))
    {
      echo "&lt;br&gt;Updating";
  
      $roll=$_POST['roll'];
      $name=$_POST['name'];
      $unit_test=$_POST['unit_test'];
      $prelims=$_POST['prelims'];
      $attendance=$_POST['attendance'];
      $file=$_POST['file'];
  
      $sql="Insert into students (roll,name,unit_test,prelims,average,attendance,file,interm) 
      VALUES ('$roll','$name','$unit_test','$prelims','$average'=(('$unit_test' + '$prelims')/125) *10,'$attendance','$file','$average'+'$attendance'+'$file')";
      $res=mysql_query($sql);
      header("Location:./view.php");
    } 
  </code></pre>