javascript - Jquery : Why is the first image repeated twice in lightbox -


i'm new jquery , php. below code, see first image gets repeated twice, while rest of images displayed properly.

 <div class="image-zoom" rel="lightbox" id="gallery">         <div id="album1" style="margin-right:18px;" rel="lightbox">             <?php             if (isset($albums[0])) {                 $i = 1;                 foreach ($albums[0]['photos'] $photo) {                     if ($i == 1) {                         ?>                         <a href="<?= $photo ?>" rel="lightbox">                             <img src="<?= $photo ?>" width="214" height="160" />                         </a>                         <div class="zoom-magnifier" id="gallery">                             <a href="<?= $photo ?>" rel="lightbox">                                 <img src="<?php echo yii::app()->theme->baseurl; ?>/images/zoom-icon.png" id="zoom"/>                             </a>                             <div id="more-text" align="left" ><?=$albums[0]['title']?></div>                         </div>                         <?php                      } else {                         ?>                         <a href="<?= $photo ?>" rel="lightbox"></a>                         <?php                     }                     $i++;                 }                           }             ?>         </div>         <div id="album2" rel="lightbox">             <?php             foreach (array(1, 0) $album_id) {                 if (isset($albums[$album_id])) {                     $i = 1;                     foreach ($albums[$album_id]['photos'] $photo) {                         if ($i == 1) {                             ?>                             <a href="<?= $photo ?>" rel="lightbox">                                 <img src="<?= $photo ?>" width="214" height="160" />                             </a>                             <div class="zoom-magnifier">                                 <a href="<?= $photo ?>" rel="lightbox">                                     <img src="<?php echo yii::app()->theme->baseurl; ?>/images/zoom-icon.png" id="zoom1"/>                                 </a>                                 <div id="more-text2" class="more-txt-link"><?=$albums[$album_id]['title']?></div>                             </div>                             <?php                         } else {                             ?>                             <a href="<?= $photo ?>" rel="lightbox"></a>                             <?php                         }                         $i++;                     }                                             break;                 }             }             ?>         </div>     </div> 

below code of lightbox script.

<script type="text/javascript" src="<?php echo yii::app()->theme->baseurl; ?>/js/jquery.lightbox-0.5.js"></script> <link rel="stylesheet" type="text/css" href="<?php echo yii::app()->theme->baseurl; ?>/css/jquery.lightbox-0.5.css" media="screen" /> <script type="text/javascript">     $(function() {         $('#album1 a').lightbox();         $('#album2 a').lightbox();     }); </script> 

so if there 5 images displayed, above code 6 images displayed first image repeated twice. how can avoid this


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -