How to pass value to popup window using php loop

I want to pass product id to popup window in the same page.how to pass id to popup window?this is my code:

Display all products from table:

<?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="../helios/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>

Popup Window code:

<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>

how can i do this.?

You’re probably going to be using json, php has functions for encoding and decoding json data. btw, are you aware that the mysql_* extension that you’ve used was removed from version 7 of PHP?

how can i set popup for this loop.?can u help me with edit of this code.??

not at all. PHP runs on the server and it doesn’t look like you’re calling the modal through the server.

how can i set popup for this loop.?can u help me with edit of this code.??

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.