嗨,所以模式在第一行工作正常,但是当我单击第二行时,模式不会获取任何数据
获取数据的表单,此内容仅在首页上起作用,或者不起作用
$ID = $_POST['ID'];
$sql = "SELECT * FROM `unity_users` WHERE `uid` = '$ID'";
$res = mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0){
$row = mysqli_fetch_assoc($res);
$htmlToReturn = '<form action="" enctype="multipart/form-data" class="formTopMargin" autocomplete="off" method="post">
<div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<div class="form-group">
<label for="cat">User Name:</label>
<input type="text" class="form-control" value="'.$row['name'].'" name = "name">
</div>
<div class="form-group">
<label for="cat">Email:</label>
<input type="email" class="form-control" value="'.$row['email'].'" name = "email">
</div>
<div class="form-group">
<label for="cat">Score:</label>
<input type="number" class="form-control" value="'.$row['score'].'" name = "score">
</div>
<div class="form-group">
<label for="cat">PPA:</label>
<input type="text" class="form-control" value="'.$row['ppa'].'" name = "ppa">
</div>
<div class="form-group">
<label for="cat">Hash:</label>
<input type="text" class="form-control" value="'.$row['hash'].'" name = "hash">
</div>
<div class="form-group">
<input type="hidden" hidden value="'.$row['uid'].'" name = "uid">
</div>
</div>
<div class="col-sm-3"></div>
</div>
<div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<button type="submit" name="update" class="btn loginButton">Update</button>
</div>
<div class="col-sm-3"></div>
</div>
</form>';
代码输出
<?php
$sql = "SELECT * FROM `unity_users`";
$res = mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0){
while ($row = mysqli_fetch_assoc($res)) {
echo '<tr>';
echo '<td>'.$row['uid'].'</td>';
echo '<td>'.$row['name'].'</td>';
echo '<td>'.$row['email'].'</td>';
echo '<td>'.$row['score'].'</td>';
echo '<td>'.$row['ppa'].'</td>';
echo '<td>'.$row['hash'].'</td>';
if($row['payment']=="Released"){
$payment = "requested";
}else{
$payment = "pending";
}
echo '<td>'.$payment.'</td>';
echo '<td class="pointer"><i id="delete_'.$row['uid'].'" class="fa fa-trash fa-2x details" aria-hidden="true"></i></td>';
echo '<td class="pointer"><i data-toggle="modal" data-target="#myModal" id="edit_'.$row['uid'].'" class="fa fa-pencil-square-o fa-2x details" aria-hidden="true"></i></td>';
echo '</tr>';
}
}
?>
模态
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 style="text-align: center;margin-top: 1%;font-size: 25px;" class="modal-title">User Data</h4>
</div>
<div class="modal-body" id="categoryModel">
</div>
</div>
</div>