dreamstopixels Posted September 21, 2013 Share Posted September 21, 2013 tHis loop displays slider image as 1,1 2,2, 3,3 4,4 5,5 Instead of 1,2,3,4,5 can anyone help me <?php $results2=$objMain->getResults("SELECT * FROM tbl_imageslider"); $products3=$objMain->getResults("SELECT * FROM tbl_products"); ?> <div class="camera_wrap camera_ash_skin" id="camera_wrap_1"> <?php if(!empty($results2)){foreach($results2 as $res2){?> <?php if(!empty($products3)){ foreach($products3 as $pro3){ ?> <div data-thumb="images/post-images/banner-thumb.jpg" data-src="<?php echo $res2['image_path']; ?>" data-alignment="topRight"> <div class="camera_caption fadeFromBottom"> <div class="slideshow-content"> <h2><?php echo $pro3['page_title']; ?><span> </span> </h2> <div class="slideshow-desc"> <p><?php echo substr($pro3['page_content'],0,125); ?></p> <a href="<?php echo $pro3['page_url']; ?>" title="" class="slideshow-btn"> Read More </a> </div> </div> </div> </div> <?php }} ?> <?php }} ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/282334-foreach-loops-twice/ Share on other sites More sharing options...
jcbones Posted September 21, 2013 Share Posted September 21, 2013 (edited) Edit, this forum hates Chromium. I'm not typing all that again.I'm sure you can do all this in one query, post the database structure. You should be selecting only the columns you wish to use, less overhead. <?php if(!empty($results2)){foreach($results2 as $res2){ //1st loop?> <?php if(!empty($products3)){ foreach($products3 as $pro3){ //2nd loop?> Edited September 21, 2013 by jcbones Quote Link to comment https://forums.phpfreaks.com/topic/282334-foreach-loops-twice/#findComment-1450557 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.