模态返回相同值的最后一条记录

时间:2016-09-07 08:47:50

标签: php html

我创建了一个表,当我点击模态时,会显示相同的值id。其中有2行记录,每当我点击数字1时,它应该显示id号1,但它总是显示最后一个记录ID号2.这是我的代码

TABLE:

    <h2 align="center">Summary Weekly Report</h2>
<div class="container-fluid">
<a href="#" class="btn">PDF</a> | <a href="#" class="btn">Add New</a>
<table>
<tr>
  <th></th>
  <th>WEEK</th>
  <th>Date&Time</th>
  <th>User</th>
  <th>Department</th>
  <th>Diagnostic Report</th>
  <th>Date Finished</th>
  <th>Performed By</th>
  <th>Remarks</th>
  <th>Repair</th>
  <th>Priority</th>
</tr>
 <?php
        include("database/db_conection.php");
        $view_users_query="select * from summary_report";//select query for viewing users.
        $run=mysqli_query($dbcon,$view_users_query);//here run the sql query.

        while($row=mysqli_fetch_array($run))//while look to fetch the result and store in a array $row.
        {
          $id=$row[0];
          $week=$row[1];
          $datetime=$row[2];
          $users=$row[3];
          $department=$row[4];
          $diagnostic=$row[5];
          $datetimefinish=$row[6];
          $performedby=$row[7];
          $remarks=$row[8];
          $repair=$row[9];
          $priority=$row[10];

?>

<tr>
  <td>
  <a href="delete-summary.php?del=<?php echo $id ?>" onclick="return confirm('Delete this report?')"class="fa fa-trash-o fa-lg" aria-hidden="true"></a>  -
  <a href="#" data-toggle="modal" data-target="#edit" class="fa fa-pencil fa-lg" aria-hidden="true"></a>
  </td>
  <td><?php echo $week ?></td> 
  <td><?php echo $datetime ?></td>
  <td><?php echo $users ?></td>
  <td><?php echo $department ?></td>
  <td width="30%"><?php echo $diagnostic ?></td>
  <td><?php echo $datetimefinish ?></td>
  <td><?php echo $performedby ?></td>
  <td><?php echo $remarks ?></td>
  <td><?php echo $repair ?></td>
  <td><?php echo $priority ?></td>
</tr>
<?php } ?>
</table>
    </div>

MODAL:

  <div class="modal fade" id="edit" role="dialog">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p><?php echo $id ?></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>

0 个答案:

没有答案