我是 php 新手,在回显数据库结果时遇到问题。div 标签上方的所有内容都可以正常执行并正确显示在我的表格中。但我遇到的问题是在 div 标签内。
while($row = mysql_fetch_array($result))
{
if ($row['status']==0){
$row['status']="Inactive";
$lablestatus="label";
}
elseif ($row['status']==1){
$row['status']="Pending";
$lablestatus="label label-warning";
}
elseif ($row['status']==2){
$row['status']="Banned";
$lablestatus="label label-important";
}
elseif ($row['status']==3){
$row['status']="Active";
$lablestatus="label label-success";
}
echo "<tr>
<td>{$row['id']}</td>
<td class='center'>{$row['username']}</td>
<td class='center'>17</td>
<td class='center'>36</td>
<td class='center'>17</td>
<td class='center'>$458.66</td>
<td class='center'>Yes</td>
<td class='center'>{$row['register_date']}</td>
<td class='center'>2013-02-13 24:06:13</td>
<td class='center'>Yes</td>
<td class='center'><span class='$lablestatus'>{$row['status']}</span></td>
<td class='center'>
<a class='btn btn-success' href='view_user.php?id={$row['id']}'>
<i class='icon-zoom-in icon-white'></i>View</a>
<a class='btn btn-info' href='edit_user.php?id={$row['id']}'>
<i class='icon-edit icon-white'></i>Edit</a>
<a class='btn btn-danger btn-setting'>
<i class='icon-trash icon-white'></i>Delete</a>
</td>
</tr>
这是问题发生的地方。当我为某个用户单击删除时,会显示一个弹出窗口。它询问“您确定要删除用户 exampleuser 吗?” 我的表中的每个用户都显示相同的用户名。因此,如果我单击删除 exampleuser2,它会询问我是否要删除 exampleuser。知道如何解决这个问题吗?
<div class='modal hide fade' id='myModal'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>×</button>
<h3>Delete member</h3>
</div>
<div class='modal-body'>
<p>Are you sure you want to delete the user {$row['username']}?</p>
</div>
<div class='modal-footer'>
<a href='#' class='btn' data-dismiss='modal'>No</a>
<a href='delete_user.php?id={$row['id']}' class='btn btn-primary'>Yes</a>
</div>
</div>";
}