title: How to insert data in drop down menu into new table in database?
body: <p>Lets say I have one table with 3 column:
  I've got data in column 1 (Id Pelajar) and column 2 (Nama Pelajar) from another table (Register).
  But how to insert data in drop down menu (column 3) into database?
  I want to insert all data in column 1, column 2 and column 3 into new table (penilai) in database.</p>
  
  <p><strong>This is my coding in penilai.php:</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  require_once "conn.php";
      $conn = connect();
      $db = connectdb();
  
  mysql_select_db($db,$conn) or die (mysql_error() . "\n");
  $query_usr = "select * from register"; //to get data from register table into column 1 and 2
  $usr = mysql_query($query_usr,$conn) or die(mysql_error()."\n".$query_usr);
  $row_usr=mysql_fetch_assoc($usr);
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;table width="400" border="0"&gt;
    &lt;center&gt;&lt;tr&gt;
      &lt;td&gt;&lt;form action="newpenilai.php" method="post"&gt;
      &lt;table width=500 border='1'&gt;
      &lt;tr&gt;
      &lt;td&gt;Id Pelajar&lt;/td&gt;
      &lt;td&gt;Nama Pelajar&lt;/td&gt;
      &lt;td&gt;Nama Penilai&lt;/td&gt;
  
      &lt;/tr&gt;
  
  &lt;?php
  require_once "conn.php";
      $conn = connect();
      $db = connectdb();
  
  mysql_select_db($db,$conn) or die (mysql_error() . "\n");
  
  $query_usr ="SELECT * FROM register";//to get data from register table into column 1 and 2
  $usr = mysql_query($query_usr,$conn) or die(mysql_error()."\n".$query_usr);
  $row_usr=mysql_fetch_assoc($usr);
  
  $result=mysql_query($query_usr);
  
      if($result)
  {
      while ($row=mysql_fetch_assoc ($result))
      {
      ?&gt;
  
      &lt;input name="id_pelajar" type="text" value="&lt;?php echo $row ["id_pelajar"];?&gt;"/&gt;
  
      &lt;input name="nama_pelajar" type="text" value="&lt;?php echo $row ["nama_pelajar"];?&gt;"/&gt;
      &lt;select name="nama_penilai"&gt;
      &lt;option&gt;-Sila pilih-&lt;/option&gt;
        &lt;option value="En Badrul Hisham"&gt;En Badrul Hisham&lt;/option&gt;
        &lt;option value="En Kamarul Zaman"&gt;En Kamarul Zaman&lt;/option&gt;
        &lt;option value="Pn Hasnita Ahmad"&gt;Pn Hasnita Ahmad&lt;/option&gt;
        &lt;option value="Pn Hazfa Amani"&gt;Pn Hazfa Amani&lt;/option&gt;
        &lt;option value="Pn Zalika Lutfi"&gt;Pn Zalika Lutfi&lt;/option&gt;
      &lt;/select&gt;
  
  &lt;?php }}?&gt;
  
  &lt;center&gt;
  &lt;input name="save" type="submit" value="Simpan"&gt;
  &lt;input name="Reset" type="reset" value="Set Semula"&gt;
  
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>This is my php code to save data into new table in database:</strong></p>
  
  <pre><code>&lt;?php
  require_once "conn.php";
      $conn = connect();
      $db = connectdb();
  
  mysql_select_db($db,$conn) or die (mysql_error() . "\n");
  
  $query_usr ="SELECT * FROM penilai";//new table
  $usr = mysql_query($query_usr,$conn) or die(mysql_error()."\n".$query_usr);
  $row_usr=mysql_fetch_assoc($usr);
  
  $nama_penilai=$_REQUEST["nama_penilai"];
  $id_pelajar=$_REQUEST["id_pelajar"];
  $nama_pelajar=$_REQUEST["nama_pelajar"];
  $result=mysql_query($query_usr);
  
  $query = "INSERT INTO penilai(nama_penilai,id_pelajar,nama_pelajar)VALUES('$nama_penilai','$id_pelajar','$nama_pelajar')";
  $result = mysql_query($query);
  
  echo "&lt;script languange = 'Javascript'&gt;
                  alert('Data  telah dimasukkan!');
                  location.href = 'view-penilai.php';&lt;/script&gt;";
  ?&gt;
  </code></pre>
  
  <p>Anyone?</p>