title: Values not inserting into database table
body: <p>I am trying to insert the values from drop-down and text box throug web page.</p>
  
  <p>first there will be one drop down box that has numbers from 1 to 25..</p>
  
  <p>when i select the number from the dropdown, the corresponding textboxes and dropdown boxes are created.</p>
  
  <p>But when i enter the data and click the submit button,the values are not going to database, instead only the last row values are inserting into database.</p>
  
  <p>for example:</p>
  
  <p>say i have selected 4 from number dropdown, now 4 rows with textbox and dropdown box appears.</p>
  
  <p>when i enter the data in the textbox and select value from dropdown and click submit. the last row values are getting inserted 4 times.</p>
  
  <p>i want it to insert the values correctly...How can i solve this.?</p>
  
  <p>here is the code i am using..</p>
  
  <p>code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link rel="stylesheet" href="css/common.css" type="text/css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/page.css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/button.css"&gt;
  &lt;link href="css/loginmodule.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='js/jquery.autocomplete.js'&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" /&gt;
  
  &lt;script type="text/javascript"&gt;
  $().ready(function() {
      $("#Fname").autocomplete("get_course_list.php", {
          width: 260,
          matchContains: true,
          //mustMatch: true,
          //minChars: 0,
          //multiple: true,
          //highlight: false,
          //multipleSeparator: ",",
          selectFirst: false
                 });
                 });
            &lt;/script&gt;
  
            &lt;script&gt;
              function showUser(str) {
                  if(str=="") {
                      document.getElementById("txtHint").innerHTML="";
                      return;
                  }
  
                  if(window.XMLHttpRequest) {
                      xmlhttp=new XMLHttpRequest();
                  } else {
                      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
  
                  xmlhttp.onreadystatechange = function() {
                      if(xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
                          document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                      }
                  }
                  xmlhttp.open("GET","gettheater.php?q="+str,true);
                  xmlhttp.send();
                  }
          &lt;/script&gt;
  
  
         &lt;script type="text/javascript"&gt;
  
  
      function create(param) {
      'use strict';
      var i, target = document.getElementById('screens');
      target.innerHTML = '';
      target.innerHTML = '&lt;input name="RowCount" value="' + param + '" hidden /&gt;';
      for(i = 0; i &lt; param; i += 1) {
  
         target.innerHTML +='&lt;/br&gt;';
         target.innerHTML +='New Movie '+i+'  ';
         target.innerHTML += '&lt;input type="text" name="Fname"&gt;';
         target.innerHTML +='  '+'Language '+'  ';
         target.innerHTML += "&lt;?php 
          try {
              $dbh = new PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
          } catch (PDOException $e) {
              echo 'Connection failed: ' . $e-&gt;getMessage();
          }
  
          $sql = 'SELECT language FROM languages;';
  
          $sth = $dbh-&gt;prepare($sql);
          $sth-&gt;execute();
  
          echo "&lt;select name='language' id='course'&gt;";
          echo "&lt;option&gt;----Select Language----&lt;/option&gt;"; 
          while($row = $sth-&gt;fetch(PDO::FETCH_ASSOC)) {
              echo "&lt;option value='" . $row['language'] ."'&gt;" . $row['language']. "        &lt;/option&gt;";
          }
          echo "&lt;/select&gt;";
  ?&gt;";
  
         target.innerHTML +='&lt;/br&gt;';
         target.innerHTML +='&lt;/br&gt;';
      }
  }
  
  
  &lt;/script&gt; 
  
  &lt;style&gt;
  
  #screens{
  color:black;
  }
  
  &lt;/style&gt;
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  
  &lt;h1&gt;Welcome &lt;?php echo $_SESSION['SESS_FIRST_NAME'];?&gt;&lt;/h1&gt;
  &lt;a href="member-profile.php" class="log"&gt;My Profile&lt;/a&gt; | &lt;a href="logout.php" class="log"&gt;Logout&lt;/a&gt;
  &lt;p&gt;This is a password protected area only accessible to Admins. &lt;/p&gt;
  
  &lt;center&gt;
  
  
  
  &lt;div class="pan"&gt;&lt;br&gt;&lt;br&gt;
  &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST" autocomplete="off"&gt;
  
  &lt;div class="head"&gt;Update Theater Information&lt;/div&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;label for="screens"&gt;New Movies Released&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;
  
  &lt;select id="select" onchange='javascript:create(this.value);' name="range"&gt;
      &lt;option&gt;--Select Number Of New Movies Released--&lt;/option&gt;
      &lt;option value="1"&gt;1&lt;/option&gt;
      &lt;option value="2"&gt;2&lt;/option&gt;
      &lt;option value="3"&gt;3&lt;/option&gt;
      &lt;option value="4"&gt;4&lt;/option&gt;
      &lt;option value="5"&gt;5&lt;/option&gt;
      &lt;option value="6"&gt;6&lt;/option&gt;
      &lt;option value="7"&gt;7&lt;/option&gt;
      &lt;option value="8"&gt;8&lt;/option&gt;
      &lt;option value="9"&gt;9&lt;/option&gt;
      &lt;option value="10"&gt;10&lt;/option&gt;
      &lt;option value="11"&gt;11&lt;/option&gt;
      &lt;option value="12"&gt;12&lt;/option&gt;
      &lt;option value="13"&gt;13&lt;/option&gt;
      &lt;option value="14"&gt;14&lt;/option&gt;
      &lt;option value="15"&gt;15&lt;/option&gt;
      &lt;option value="16"&gt;16&lt;/option&gt;
      &lt;option value="17"&gt;17&lt;/option&gt;
      &lt;option value="18"&gt;18&lt;/option&gt;
      &lt;option value="19"&gt;19&lt;/option&gt;
      &lt;option value="20"&gt;20&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;
  &lt;div id="screens"&gt;
  
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" class="button" name='submit' value="Submit" /&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;/table&gt; 
  &lt;/form&gt;&lt;br&gt;&lt;br&gt;
  &lt;/div&gt;
  
  &lt;?php
  mysql_connect("localhost", "tiger", "tiger") or die(mysql_error());
  mysql_select_db("theaterdb") or die(mysql_error());
  for ($i=0; $i &lt; $_POST["range"] ; $i++)
  {
  $query = mysql_query("INSERT INTO movie (movie_name,language) VALUES('$_POST[Fname]','$_POST[language]') ") or die(mysql_error());
  }
  ?&gt;
  
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>