我正在尝试为获取的行传递每个模态的ID。如果我尝试获取edit_id值,它将始终返回第一个获取的值。我错过了什么?有人能帮帮我吗?
while($row=mysqli_fetch_row($result_set)){?>
<li class="gen-row">
<div class="gen">
<div class="gen-controls">
<div class="gen-control"><a href="#" data-toggle="modal" data-target="#myModal<?php echo $row[0]; ?>"><span class="glyphicon glyphicon-pencil"></span></a></div>
<!-- Edit Modal -->
<div class="modal fade" id="myModal<?php echo $row[0]; ?>" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Erstellen Sie ein neues Genogramm </h4>
</div>
<div class="modal-body">
<form action="edit_data.php" method="post" id="genogramm-anlegen">
<input type="text" id="edit_id" name='edit_id' value='<?php echo $row[0]; ?>'>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" form="genogramm-anlegen" name="btn_edit">Speichern</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>
</div>
</div>
</div>
</li>
<?php
}
edit_data.php:
if(isset($_POST['btn_edit'])) {
$user_id = mysqli_real_escape_string($link, $_REQUEST['edit_id']);
echo $user_id;