简体   繁体   中英

Fancybox didn't work while getting images from database (php)

<?php
 $sqlInner=" select * from gallery_photos where series_id='".$row['id']."' ";
 $rr = mysql_query($sqlInner,$con); 
 while($data=mysql_fetch_array($rr))    {
    echo"<a class='fancybox' rel='gallery' href='images/gallery_photos/".$data['photo_path']."'><img src='images/gallery_photos/".$data['photo_path']."'width='150' height='150' ></a>";
 }
?>


 <script type="text/javascript">
  $(document).ready(function() {
    $(".fancybox").fancybox({'type' : 'image'})
});
</script>

it didn't work for me, I'm just a beginner. Help needed.

Thanks in advance.

is it working fine with static images? If yes then try below code

<script type="text/javascript">
    $(document).ready(function() {
     $(".fancybox").fancybox({type : 'image'})
    });
</script>

try to remove "type:image":

<script type="text/javascript">
$(document).ready(function() {
    $(".fancybox").fancybox();
});

Try adding data-fancybox-type="image" property to anchor tags. It worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM