php jquery 弹出消息框在 while 循环中工作,但在弹出地址字段中显示所有条目的相同地址,任何人都可以告诉我哪里做错了提前谢谢
HTML Jquery 脚本
<script type="text/javascript">
$(document).ready(function() {
$('#button').click(function(e) {
$('#modal').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
});
</script>
HTML 表格和 Php 页面
<table>
$query1=mysql_query("select * from customers order by id desc");
while($row1=mysql_fetch_array($result))
{
?>
<tr>
<td><div align="center"><?php echo $row1['firstname']; ?></div></td>
<td><div align="center"><?php echo $row1['lastname']; ?></div></td>
<td><div align="center"><?php echo $row1['dob']; ?></div></td>
<td><div align="center"><?php echo $row1['email']; ?></div></td>
<td><div align="center"><a href="#" class="button">Address</a></div></td>
<td><div align="center"><?php echo $row1['phone']; ?></div></td>
<td><div align="center"><?php echo $row1['country']; ?></div></td>
<td><div align="center"><?php echo $row1['city']; ?></div></td>
</tr>
<Popup Start>
<div id="modal">
<div id="heading">
Sign Up! Customer's Address
</div>
<div id="content">
<p><?php echo $row1['address']; ?></p>
</div>
</div>
<Popup End>
<?php }?>
</table>
最佳答案
在 HTML 中
将此行更改为:
<td><div align="center"><a href="#" id="button">Address</a></div></td>
这个:
<td><div align="center"><a href="#" class="button">Address</a></div></td>
&
将此行更改为:
<div id="modal">
这个:
<div class="modal">
Javascript:
$('.button').click(function(e) {
$(this).closest('tr').find('.modal:first').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
关于在while循环中工作的php jquery弹出消息框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14910195/