title: Insert multiple (fk) data in one of the two phpMyAdmin table
body: <p>**Hi. These are my structures :</p>
  
  <p>I got 2 tables in phpMyAdmin :</p>
  
  <ul>
  <li>Class ( classid(pk), className )</li>
  <li>Students ( studentid(pk), classid(fk), studentName )
  1 form.php and 1 form_post.php</li>
  </ul>
  
  <p>I've done this in form.php**</p>
  
  <pre><code>include_once("connection.php");
  
  
      $className= $_POST["className"];
      $studentName1= $_POST["studentName1"];
      $studentName2= $_POST["studentName2"];
      $studentName3= $_POST["studentName30"];
  
  
      $sql = "insert into class(className) values ('$className')";
  
  
      mysql_query($sql);
  
      $lastid=mysql_insert_id();
  
  
      $sql2= "INSERT INTO students (studentid, classid, studentName)
              VALUES (' ', $lastid, '$studentName')";
  
      mysql_query($sql2);
  </code></pre>
  
  <p><strong>form_post.php :</strong></p>
  
  <pre><code>            &lt;tr&gt;
                &lt;td width="140"&gt;&lt;span class="order"&gt;Class Name: &lt;/span&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span class="order"&gt;
                  &lt;input name="className" type="text" id="className" size="35" /&gt;
                &lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td width="132"&gt;&lt;span class="order"&gt;Student's Name: &lt;/span&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span class="order"&gt;
                  &lt;input type="text" name="studentName1" id="studentName1" /&gt;
                &lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
             &lt;tr&gt;
                &lt;td width="132"&gt;&lt;span class="order"&gt;Student's Name: &lt;/span&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span class="order"&gt;
                  &lt;input type="text" name="studentName2" id="studentName2" /&gt;
                &lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td width="132"&gt;&lt;span class="order"&gt;Student's Name: &lt;/span&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span class="order"&gt;
                  &lt;input type="text" name="studentName3" id="studentName3" /&gt;
                &lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
  </code></pre>
  
  <p>It's a form for registering class and students in it.
  In phMyAdmin student table, there's a field/column for studentid(pk), a field/column for classid(fk), a field/column for studentName  while this code which I got from my friend got 3 students name field. How to insert the 3 students name into the phpMyAdmin student table's studentName column with the same class foreign key?
  The red colored words are the confusing one.
  I'm still a beginner and  I tried all the night to get this work. But, I'm still stuck.
  Thank you :)</p>