title: Get ID of each row in modal by pressing edit button
body: <p>Here is my code of table. I want to get ID of each row in opened modal when press button "EDIT".  How can I send ID of selected row to modal? In my case bellow i am getting only first row ID.  </p>
  
  <p>Thank you for attention.</p>
  
  <p>JS for modal form
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
  $(".btn[data-target='#myModal']").click(function() {
         var columnHeadings = $("thead th").map(function() {
                   return $(this).text();
                }).get();
         columnHeadings.pop();
         var columnValues = $(this).parent().siblings().map(function() {
                   return $(this).text();
         }).get();
    var modalBody = $('&lt;div id="modalContent"&gt;&lt;/div&gt;');
    var modalForm = $('&lt;form role="form" name="modalForm" action="putYourPHPActionHere.php" method="post"&gt;&lt;/form&gt;');
    $.each(columnHeadings, function(i, columnHeader) {
         var formGroup = $('&lt;div class="form-group"&gt;&lt;/div&gt;');
         formGroup.append('&lt;label for="'+columnHeader+'"&gt;'+columnHeader+'&lt;/label&gt;');
         formGroup.append('&lt;input class="form-control" name="'+columnHeader+i+'" id="'+columnHeader+i+'" value="'+columnValues[i]+'" /&gt;'); 
         modalForm.append(formGroup);
    });
    modalBody.append(modalForm);
    $('.modal-body').html(modalBody);
  });
  $('.modal-footer .btn-primary').click(function() {
     $('form[name="modalForm"]').submit();
  });
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>      &lt;table class="simple-little-table table" cellspacing='0'&gt;
  
          &lt;tr&gt;
              &lt;th&gt;&lt;p&gt;&amp;#8470;&lt;/p&gt;&lt;/th&gt;
              &lt;th&gt;&lt;p&gt;Name, Surname&lt;/p&gt;&lt;/th&gt;
              &lt;th&gt;Own number&lt;/th&gt;
              &lt;th&gt;Company Number&lt;/th&gt;
      &lt;/tr&gt;
  
  
       &lt;?php  
          $result =mysql_query("SELECT * FROM `my_table` WHERE 1 and status=1");
          while ($row = mysql_fetch_array($result, MYSQL_NUM))
      {
      $id=$row["0"];
      echo '&lt;tr&gt;
                          &lt;td&gt;&lt;p&gt;'.$row[1].' '.$row[2].'&lt;/p&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;p&gt;'.$row[4].'&lt;/p&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;p&gt;'.$row[5].'&lt;/p&gt;&lt;/td&gt;';
      ?&gt;
      &lt;td&gt;&lt;?php echo '&lt;button class="btn btn-success" data-toggle="modal" data-target="#myModal" contenteditable="false" value=".$id."&gt;'.$id.'&lt;/button&gt;';?&gt;&lt;/td&gt;
  
                                  &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;button type="button" class="close" data-dismiss="modal"&gt; &lt;span aria-hidden="true" class=""&gt;?   &lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;
  
                  &lt;/button&gt;
  
                  &lt;!--Here I am trying to echo ID--&gt;
                  &lt;h4 class="modal-title" id="myModalLabel"&gt;&lt;?php echo $row[0]; ?&gt;&lt;/h4&gt;
  
              &lt;/div&gt;
              &lt;div class="modal-body"&gt; sadasdas&lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                  &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
   &lt;?php
           }
           ?&gt;
  </code></pre>
  
  
  
  <p>Here is picture of table
  <a href="https://i.stack.imgur.com/wqOJp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqOJp.jpg" alt="enter image description here"></a></p>
  
  <p>I need to get ID of row in modal
  <a href="https://i.stack.imgur.com/JgGN5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JgGN5.jpg" alt="enter image description here"></a></p>