title: Submit form in to database using ajax in while loop
body: <p>I am trying to insert value in database through ajax. There rows which are coming in while loop from database. I have added one column in each row which have button. On click of button I am submitting the values in database its working fine.</p>
  
  <p>But problem is that it inserts value from first row only. Need help. Thanks in advance.  </p>
  
  <p>Not getting solution for problem</p>
  
  <p>PHP Code :</p>
  
  <pre><code>&lt;td&gt;&lt;div class="form_style"&gt;  
  &lt;input type="hidden" name="crs" id="crs" value="&lt;?php echo $crs; ?&gt;"&gt;     
  &lt;input type="hidden" name="clg" id="clg" value="&lt;?php echo $clg; ?&gt;"&gt;     
  
      &lt;button id="FormSubmit"&gt;Apply Now&lt;/button&gt;    
      &lt;img src="images/loading.gif" id="LoadingImage" style="display:none" /&gt;     
      &lt;/div&gt;&lt;/td&gt;   
  </code></pre>
  
  <p>Ajax and javascript Code :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;   
  $(document).ready(function() {     
  
      $("#FormSubmit").click(function (e) {   
              e.preventDefault();   
  
              $("#FormSubmit").hide(); 
              $("#LoadingImage").show(); 
  
              var myData = {
                      crs: $('#crs').val(),
                      clg: $('#clg').val()
  
                    };
  
              jQuery.ajax({
              type: "POST", 
              url: "response.php",
              dataType:"text", 
              data:myData, 
              success:function(response){
                  $("#responds").append(response);
                  $("#crs").val(''); 
                  $("#clg").val('');
                  $("#FormSubmit").show(); 
                  $("#LoadingImage").hide(); 
  
              },
              error:function (xhr, ajaxOptions, thrownError){
                  $("#FormSubmit").show(); 
                  $("#LoadingImage").hide(); 
                  alert(thrownError);
              }
              });
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Response.php</p>
  
  <pre><code>&lt;?php
  
  
  
  
      $crs = $_POST["crs"]; 
      $clg = $_POST["clg"]; 
  
  
  
      $strsreg="insert into add_delete_record  (id, content, content1) values('', '$crs', '$clg')";
      $resultsreg=mysql_query($strsreg) or die(mysql_error());
  
  
  
  ?&gt;
  </code></pre>