我想将产品ID传递到同一页面的弹出窗口。如何将id传递给弹出窗口?这是我的代码:
显示表格中的所有产品:
<?php $data = mysql_query("select * from tbl_product") ;
while($dat=mysql_fetch_array($data))
{
$id=$dat['id']
?>
<a href="<?php echo $id ?> " class="mymodel" data-detail-id=<?php echo $id ?> data-toggle="modal" data-target="#myModal">
<div class="col-sm-4 col-xs-12" style="cursor:pointer;">
<div class="col-md-12" >
<img src="../admin/product_image/<?php echo $dat['image'] ?>" >
<h4><?php echo $dat['name'] ?></h4>
</div></div></a>
<?php } ?>
的javascript:
<script type="text/javascript">
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus()
})</script>
弹出窗口代码:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<?php
$data = mysql_query("select * from tbl_product where id='$id'") ;
while($dat=mysql_fetch_array($data))
{
$id=$dat['id'] ;
}
?>
<div class="col-md-6" style="margin-bottom:30px;">
<?php echo $id ?>
</div>
</div></div>