在bootstrap模式弹出窗口中获取data-id属性,并使用PHP中的data-id从数据库中获取字段

<a href="#" data-toggle="modal" data-id="<?php echo $row['rel_id'];?>" class="open-AddBookDialog"  data-target="#lightbox"><img src="../AbaamAdmin/Released_Movies/<?php echo $row['rel_movies_pics'];?>" style="width:330px;height:300px;" ></a> 

When I click the above link I need to get the data-id value, and I need to fetch images from database using this value and need to create a image slideshow. The bootstrap modal poopup code is also in the same page. The below is my popup code.

<div class="modal fade and carousel slide" id="lightbox">
<div class="modal-dialog" style="margin-top:250px;vertical-align:middle;" >
  <div class="modal-content">
    <div class="modal-body">


      <div class="carousel-inner">

      <?php 

      $id=$_SESSION['relid'];

      //$i=0;
      $qry="select rel_movies from released_movies where rel_id='$id' ";
      $qryr=$con->query($qry);
      while($rr=$qryr->fetch_assoc())
      {
      $film=$rr['rel_movies'];

      $q="select * from gallery where category='$film'";
      $qr=$con->query($q);


      while($r=$qr->fetch_assoc())
      { 
       $rows[] = $r;
       }

      ?>
            <ol class="carousel-indicators">
        <?php
            $i = 1; //Counter
            foreach ($rows as $r): //Foreach
            $ol_class = ($i == 1) ? 'active' : ''; //Set class active for only indicator which belongs to respective Image
        ?>
         <!--Here I add the counter to data-slide attribute and add class to indicator-->
        <li data-target="#lightbox" data-slide-to="<?php echo $i;?>"  class="<?php echo $ol_class; ?>"></li>
        <?php $i++; ?>
        <?php endforeach; ?> <!--Close Foreach-->
        </ol>
       <?php
        $i = 1; //Counter
        foreach ($rows as $r): //Foreach
        $item_class = ($i == 1) ? 'item active' : 'item'; //Set class active for image which is showing
        ?>              
        <div class="<?php echo $item_class; ?>"> <!-- Define Active Class Here-->
            <img src="../AbaamAdmin/uploads/<?php echo $r['images'];?>" width="900px" height="500px" >
        </div>
        <?php $i++; ?>
        <?php endforeach; ?> <!-- Close Foreach-->



      </div> <!-- /.item active-->



      <a class="left carousel-control" href="#lightbox" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
      </a>
      <a class="right carousel-control" href="#lightbox" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
      </a>
            <?php }?>
       </div> <!-- /.carousel-inner -->

    </div><!-- /.modal-body -->
  </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

In place of $id=$_SESSION['relid']; I need to get the value from data-id. How this is possible. Thanks in advance.