How to exclude id in the loop?
-
Hi everybody, i’ve got pictures, every picture got id and i’ve got 2 loops, one loop creating current picture, another loop creating another pictures, but i need to exclude current picture from second loop, how can i do this?
Here is my code;
<div class="slider-for"> <?php $image_id = $_GET['image_id']; $num = 0; ?> <?php foreach ( $images as $image ): ?> <?php $num ++; if ( $num == $image_id ) { ?> <div class="slf-item"> <div class="slide-content"> <h3 class="headline"><?php echo $image['title']; ?></h3> <p><?php echo $image['text']; ?></p> </div> <div class="leftphoto"> <img src="<?php echo deco_thumb( $image['image'], 355, 497 ); ?>" alt=""/> <span class="img-caption"> <?php echo $image['caption']; ?> </span> </div> </div> <?php $old_id = $image_id; break; } ?> <?php endforeach; ?> <?php foreach ( $images as $image ): ?> <?php $num ++; if ( $num != $image_id && $num != $old_id ) { ?> <div class="slf-item"> <div class="slide-content"> <h3 class="headline"><?php echo $image['title']; ?></h3> <p><?php echo $image['text']; ?></p> </div> <div class="leftphoto"> <img src="<?php echo deco_thumb( $image['image'], 355, 497 ); ?>" alt=""/> <span class="img-caption"> <?php echo $image['caption']; ?> </span> </div> </div> <?php } ?> <?php endforeach; ?> </div>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to exclude id in the loop?’ is closed to new replies.