Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/282334-foreach-loops-twice/
Share on other sites

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 by jcbones
Link to comment
https://forums.phpfreaks.com/topic/282334-foreach-loops-twice/#findComment-1450557
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.