title: Model showing me first row data every time
body: <p>Model showing me only first row data on every click. How do I fix this?</p>
  
  <p>I have displayed a table of records using the php <code>while</code> loop. Also, one row has a button which is the View button. After clicking on this button I want show information of that id.</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;div class="panel"&gt;
              &lt;header class="panel-heading"&gt;
                  Subject Material Detail View
              &lt;/header&gt;
              &lt;div class="panel-body table-responsive"&gt;
                  &lt;div class="box-tools m-b-15"&gt;
                      &lt;div class="input-group"&gt;
                          &lt;input type="text" name="table_search" class="form-control input-sm pull-right" style="width: 150px;" placeholder="Search"/&gt;
                          &lt;div class="input-group-btn"&gt;
                              &lt;button class="btn btn-sm btn-default"&gt;&lt;i class="fa fa-search"&gt;&lt;/i&gt;&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;table class="table table-hover"&gt;
                      &lt;tr&gt;
                          &lt;th&gt;No.&lt;/th&gt;
                          &lt;th&gt;User&lt;/th&gt;
                          &lt;th&gt;Subject&lt;/th&gt;
                          &lt;th&gt;Title&lt;/th&gt;
                          &lt;th&gt;Description&lt;/th&gt;
                          &lt;th&gt;Modified On&lt;/th&gt;
                      &lt;/tr&gt;
  
  
                      &lt;?php
  
                          include("includes/config.php");
                          global $con;
  
                          $get_sm = ("select * from m_study_material");
                          $run_sm = mysqli_query($con, $get_sm);
  
                          $i = 0;
                          while ($row_sm = mysqli_fetch_array($run_sm)){
                              $subm_id = $row_sm['sm_id'];
                              $subm_created = $row_sm['created_by'];
                              $subm_subject = $row_sm['sm_subject'];
                              $subm_title = $row_sm['sm_title'];
                              $subm_desc = $row_sm['sm_description'];
                              $subm_modified = $row_sm['modified_on'];
                              $subm_image = $row_sm['sm_image'];
  
                      ?&gt;  
  
                      &lt;tr&gt;&lt;?php echo $subm_id; ?&gt;
                          &lt;td&gt;&lt;?php echo $i; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $subm_created; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $subm_subject; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $subm_title; ?&gt;&lt;/td&gt;
  
                          &lt;td&gt;
  
                          &lt;a href="#myModal" data-toggle="modal" target="&lt;?php echo $subm_id; ?&gt;" class="btn btn-xs btn-success"&gt;
                              View
                          &lt;/a&gt;
  
          &lt;!-- View Modal starts Here--&gt;
                &lt;div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade"&gt;
                    &lt;div class="modal-dialog"&gt;
                        &lt;div class="modal-content"&gt;
                            &lt;div class="modal-header"&gt;
                                &lt;button aria-hidden="true" data-dismiss="modal" class="close" type="button"&gt;×&lt;/button&gt;
                                &lt;h4 class="modal-title"&gt;Description&lt;/h4&gt;
                            &lt;/div&gt;
                            &lt;div class="modal-body"&gt;
  
                                        &lt;p class="help-block"&gt;
  
                                        &lt;?php echo $subm_desc; ?&gt;
  
                                        &lt;/p&gt;
  
                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
          &lt;!-- View Modal ends Here--&gt;        
                  &lt;/td&gt;
  
                  &lt;td&gt;&lt;span class="label label-success"&gt;&lt;?php echo $subm_modified; ?&gt;&lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;   
  
              &lt;?php $i++; } ?&gt;
  
  
                  &lt;/table&gt;
              &lt;/div&gt;&lt;!-- /.box-body --&gt;
          &lt;/div&gt;&lt;!-- /.box --&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>