Bootstrap Modal不适用于表中的所有记录

问题描述

我已经制作了一个引导模式,用于使用PHP中的while循环分别更新表中的每个记录,但是它似乎仅适用于表的第一条记录。我无法弄清楚哪里出了问题。请帮助我,让我知道我要去哪里了。

这是代码

<!DOCTYPE html>
<html>
<body>
<?PHP
  $sql = "SELECT * FROM fee_status";
  $result = $conn->query($sql);
  $i = 1;
  if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
?>
<table>
  <tr>
    <td width='5%'><?PHP echo $i++; ?></td>
      <td width='20%'><?PHP echo $row["student_id"]; ?><br><?PHP echo $row["student_name"]; ?></td>
      <td width='10%'><?PHP echo $row["fee_due"]; ?></td>
      <td width='25%'>
        <div class="dropdown">
          <button class='btn btn-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>Actions</button>
          <div class='dropdown-menu' aria-labelledby='dropdownMenuButton'>
            <a class='dropdown-item' data-toggle='modal' data-target="#myModal<?PHP echo $row['student_id']; ?>">Update Payment</a>
          </div>
        </div>
      </td>
    </tr>
</table>
      <div class="modal" role="dialog" id="myModal<?PHP echo $row['student_id']; ?>">
          <div class="modal-dialog" role="document" style="max-width: 65%;">
            <div class="modal-content">
              <div class="modal-header">
                  <h5 class="modal-title">Update Payment</h5>
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
              </div>
              <div class="modal-body">
                <form id="update_payment_form" class="form-group" action="update_fee.PHP" method="post">
                  <div class='form-group required'>
                    <div class="row">
                      <div class="col-md-6">
                        Student Details: <input type="text" name="student_details" value='<?PHP echo $row['student_id']; ?> - <?PHP echo $row['student_name']; ?>' style='width: 70%;' readonly>
                      </div>
                      </div>
                    <br>
                    <div class="row">
                      <div class="col-md-6">
                        Amount: <input type="number" name="new_payment" placeholder='<?PHP echo $row['fee_due']; ?>' style='width: 40%;' required>
                      </div>
                    </div>
                    <br>
                    <div class="row">
                      <div class="col-md-6">
                        Date:&nbsp;&nbsp;&nbsp;<input id="date-field" type="date" name="date" style='width: 40%;'>
                      </div>
                    </div>
                </div>
              </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" onclick="form_submit()" class="btn btn-primary">Update</button>
            </div>
          </div>
        </div>
      </div>
    <?PHP
      }
    }
?>
</body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)