0
   <div id="slider-edge">
        <div class="left-side-shadow"></div><!-- End .left-side-shadow -->
        <div class="right-side-shadow"></div><!-- End .left-side-shadow -->
        <div id="bxslider" class="container">
            <ul class="bxslider">
                <li>
                   <?php
                    $i =1;
                    $spro = $obj->limitallpro(4);
                    foreach($spro as $sspro){


                    ?>
                    <div class="slider-item">
                      <img src="images/products/big-phone1.jpg" alt="Slider item 3" width="400" height="400">
                        <div class="slider-item-details">
                            <div class="slider-item-wrapper">
                                <h3 class="item-name">
                                    <a href="product.html"><?php echo($sspro['pname']);?></a>
                                </h3>
                                <div class="item-price-container">
                                    <span class="item-price"><?php echo("".$sspro['pprice']." ");?>RS</span>
                                </div><!-- End .item-price-container -->
                                <p><?php echo($sspro['pdetails']);?></p>

                            <a href="cart.php/pid=<?php echo($sspro['pid']);?>" class="item-add-btn">
                                Add to Cart
                            </a>
                            </div><!-- End .slider-item-wrapper -->

                        </div><!-- End .slider-item-details -->
                    </div><!-- End .slider-item -->
                   <?php

                    ?>  



                      <?php
                    if($i%2 == 0){
                    ?>  
                     </li><li>



                    <?php
                    }
                        $i++;
                    }?>

            </ul>
        </div><!-- End #bxslider -->
        </div><!-- #slider-edge -->

I have slider which work as two div per li since i am trying to get conttent from server side what can i do then after every 2 rows of data from server it creates another li and then repeat 2 rows and close it and let it work as long as rows be keep added through server side. i used if case with modulus but that is not working

2
  • Not working is quite broad. Could you narrow it down? What does not work? Commented Jun 14, 2017 at 18:19
  • i have limit it to get 4 rows from my product page as slider is designed that works as two div with slider-item class after that it close </li> and open another <li> if i use it statically but since i want it to work dynamically how could it create <li> and add rest 2 rows then close it </li> it self it will work with if else but i am not sure how could condition can be created. i have used modulus for whenever it get 2 but stll it not giving me proper functionality glitching products like showing same and more. etc etc. Commented Jun 14, 2017 at 18:24

3 Answers 3

1
<div id="slider-edge">
    <div class="left-side-shadow"></div><!-- End .left-side-shadow -->
    <div class="right-side-shadow"></div><!-- End .left-side-shadow -->
    <div id="bxslider" class="container">
        <ul class="bxslider">
            <li>
               <?php
                $i =1;
                $spro = $obj->limitallpro(4);
                foreach($spro as $sspro){


                ?>
                <div class="slider-item">
                  <img src="images/products/big-phone1.jpg" alt="Slider item 3" width="400" height="400">
                    <div class="slider-item-details">
                        <div class="slider-item-wrapper">
                            <h3 class="item-name">
                                <a href="product.html"><?php echo($sspro['pname']);?></a>
                            </h3>
                            <div class="item-price-container">
                                <span class="item-price"><?php echo("".$sspro['pprice']." ");?>RS</span>
                            </div><!-- End .item-price-container -->
                            <p><?php echo($sspro['pdetails']);?></p>

                        <a href="cart.php/pid=<?php echo($sspro['pid']);?>" class="item-add-btn">
                            Add to Cart
                        </a>
                        </div><!-- End .slider-item-wrapper -->

                    </div><!-- End .slider-item-details -->
                </div><!-- End .slider-item -->
               <?php

                ?>  

               </li>

                  <?php
                if($i%2 == 0){
                ?>  
                 <li>



                <?php
                }
                    $i++;
                }?>

        </ul>
    </div><!-- End #bxslider -->
    </div><!-- #slider-edge -->

here close the php inside the same li where you have open the php and where is the second li being close hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

you put <.li> inside foreach loop which will close li after single div means single div per li that will not help me. still thanks.
1

I am not really sure what your problem is but if I understand correctly, that you everytimes have an open <li>-Tag after your content is rendered?!

You have to check if your loop is in the last iteration and in this case only echo an </li>.

Try

for ($i = 0; $i < count($spro); $i++) {
.........
if($i == count($spro)-1) { echo("</li>"); }
else { echo("</li><li>"); }
}

2 Comments

your solution is only letting it create one div with same row every time.
The problem is that I did not really understand what your problem is. Could you send a screenshot and tell again what you want to do? (Please in better English and with punctuation marks)
1

In your code try replacing your following code:

<?php
if($i%2 == 0){
?>  
</li><li>



<?php
}
$i++;
}?>

with this:

<?php
if($i%2 == 0){
    echo "</li><li>";
}
$i++;
}
?>
</li>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.