Sunday, June 12, 2016

How to view 2 data from sql table in bootstrap carousel with codeigniter


How to view 2 data from sql table in bootstrap carousel with codeigniter
If you want to view multiple data in a carousel you can use this code
change the column variable with 3 if you want to view 3 data at once


<div id="myCarousel" class="carousel slide carousel-fade">
    <!-- Dot Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <?php
        if (sizeof($testimonis) % 2 == 0) {
            $loop = sizeof($testimonis) / 2;
        } else {
         
            $loop = sizeof($testimonis) / 2 ;
             $loop=  round($loop);
        }
        for ($i = 1; $i < $loop ; $i++) {
            ?>
            <li data-target="#myCarousel" data-slide-to="<?php echo $i; ?>"></li>
        <?php } ?>
    </ol> <div class="carousel-inner">

        <?php
        $counter = 0;
        foreach ($testimonis as $testimoni) {
            if ($counter % 2 == 0) {
                if ($counter == 0) {
                    echo '<div class=" active item"><div class="row" style="height:300px">';
                } else {
                    echo '<div class="item"><div class="row" style="height:300px">';
                }
            }
            ?>
            <div class="col-md-6"><span class=""><?php echo $testimoni->testimoni; ?></span><br><br><span class=""><?php echo $testimoni->nama; ?></span></div>

            <?php
       
            $counter++;
              if ($counter % 2 == 0) {
                echo '</div></div>';
            }
        }
        ?>
    </div> </div> </div> </div>

No comments:

Post a Comment