Dynamic Bootstrap carousel codeigniter

 I have a working Bootstrap carousel with images source insert into HTML code. This means that every one of your carousel items has the active class. As the docs describe, only one of them should be active, and that's the one that will be displayed first.



 (toc) #title=(Table of Content)

<div class="col-xl-6 col-lg-6 col-12">

  <div id="demo" class="carousel slide" data-interval="3000" data-ride="carousel">

    <!-- Indicators -->

    <ul class="carousel-indicators">

      

      <?php $i=0; foreach ($banner as $value) {   if($i==0) $active = "active";else  $active = ""; ?>

      <li data-target="#demo" data-slide-to="<?php echo $i; ?>" class="<?php echo $active ?>" ></li>

      

      <?php $i++; } ?>

    </ul>

    

    <!-- The slideshow -->

    

    <div class="carousel-inner">

      

      <?php  $i=0; foreach ($banner as $value) { $i++;  if($i==1) $active = "active";else  $active = "";?>

      <div class="carousel-item <?php echo $active ?>">

        <img src="<?php echo base_url().$value->banner_image ?>" alt="Chicago" width="1100" height="500">

      </div>

      <?php } ?>

    </div>

    <!-- Left and right controls -->

    <a class="carousel-control-prev" href="#demo" data-slide="prev">

      <span class="carousel-control-prev-icon"></span>

    </a>

    <a class="carousel-control-next" href="#demo" data-slide="next">

      <span class="carousel-control-next-icon"></span>

    </a>

  </div>

</div>(code-box)

 banner value change

 foreach ($banner as $value)  -- VALUE FOREACH

<?php echo base_url().$value->banner_image ?> ---- IMAGE URL DATABASE

Our website uses cookies to enhance your experience. Learn More
Accept !