dqfr90979 2015-11-12 06:55
浏览 99

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么