在while循环中工作的php jquery弹出消息框

标签 php jquery mysql

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/

相关文章:

jquery bootgrid 与 requestHandler/post 重新加载有关的问题

jQuery AJAX 超时未定义

php - 如何检查 session 是否已启动并重定向用户?

php - $_SESSION ['id'] 为空

javascript - php 中未读取 Span 变量

javascript - 迭代 tr 时,Jquery 不允许我选择 td 的值

mysql - MySQL 查询的性能问题

php - 具有重复项的数组中值的总和

MySQL 数据库错误 #1064 语法错误

PhpStorm + Xdebug = 页面未加载