title: Display specific row data in bootstrap modal with edit button click
body: <p>I am new to programming and trying to implement bootstrap modal to display row data from a mysql table into the modal window.</p>
  
  <p>I have tried the solution found on stackoverflow "Pull information from mysql table to bootstrap modal to edit" by link. But could not able to display the particular row with the $row['SFID']. </p>
  
  <p>I can pull table data but when I click the edit button in front of any row it always show the last row id </p>
  
  <p>and doesn't display the data in the input box on the modal to edit the data???. </p>
  
  <p>Here I am till now, Please help me out.</p>
  
  <pre><code>&lt;table class="table table-bordered" width="100%"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;SFID&lt;/th&gt;
              &lt;th&gt;Company&lt;/th&gt;
              &lt;th&gt;Product&lt;/th&gt;
              &lt;th&gt;Product Line&lt;/th&gt;
              &lt;th&gt;Dealer Class&lt;/th&gt;
              &lt;th&gt;Status&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;?php
          $query = "SELECT * FROM tblcustomer";
          $stmt = $db-&gt;prepare($query);
          $stmt-&gt;execute();
  
          foreach ($stmt as $row): ?&gt;
              &lt;tr&gt;
      &lt;?php $rowID = $row['SFID']; ?&gt;
  
                  &lt;td&gt;&lt;?php echo $row['SFID']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['CompanyName']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['Product']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['ProductLine']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['DealerClass']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['RequestStatus']; ?&gt;&lt;/td&gt;
                  &lt;td style="text-align: center"&gt;
                      &lt;div class="btn-toolbar"&gt;
                          &lt;div class="btn-group"&gt;
                              &lt;a class="btn btn-danger" href="#delModal"  data-toggle="modal"&gt;&lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; Delete&lt;/a&gt;
  
              &lt;?php echo "&lt;a class='btn update' href='#editModal' data-sfid='".$row['SFID']."' role='button' data-toggle='modal'&gt;Edit&lt;/a&gt;"; ?&gt;
   &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/td&gt;
               &lt;/tr&gt;
       &lt;?php endforeach; ?&gt;
   &lt;/table&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>     &lt;div id="editModal" class="modal hide fade in" style="display: none; "&gt;
   &lt;div class="modal-header"&gt;
      &lt;a class="close" data-dismiss="modal"&gt;×&lt;/a&gt;
      &lt;h3&gt;Edit Customer Details&lt;/h3&gt;
  &lt;/div&gt;
   &lt;div&gt;
  &lt;form class="contact"&gt;
     &lt;fieldset&gt;
      &lt;div class="modal-body"&gt;
          &lt;?php echo $row['SFID']; ?&gt; 
          &lt;ul class="nav nav-list"&gt;
          &lt;li class="nav-header"&gt;SFID&lt;/li&gt;
          &lt;li&gt;&lt;input class="input-xlarge" type="text" name="mysfid" id="mysfid"&gt;&lt;/li&gt;
          &lt;!--&lt;li class="nav-header"&gt;Company&lt;/li&gt;
          &lt;li&gt;&lt;input class="input-xlarge" value=" " type="text" name="mycompany"&gt;&lt;/li&gt;
          &lt;li class="nav-header"&gt;Dealer Class&lt;/li&gt;
          &lt;li&gt;&lt;input class="input-xlarge" value=" " type="text" name="mydealerclass"&gt;&lt;/li&gt; --&gt;
          &lt;/ul&gt; 
       &lt;/div&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
   &lt;/div&gt;
   &lt;div class="modal-footer"&gt;
      &lt;button class="btn btn-success" id="submit"&gt;Approved&lt;/button&gt;
        &lt;a href="#" class="btn" data-dismiss="modal"&gt;Close&lt;/a&gt;
   &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>  &lt;script&gt;
      $(document).ready(function(){
      $('a.edit').click(function(){
      var sfid = $(this).data('sfid');
      var company = $(this).data('company');
      var dealerclass = $(this).data('dealerclass');    
  
      $('#mysfid').val(sfid);
      $('#mycompany').val(company);
      $('#mydealerclass').val(dealerclass);
      });
  
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>Thanks for your help.</p>