monkey232
monkey232

Reputation: 57

Trying to make a bootstrap carousel slide dynamic with a database using php

The below html just shows the images one by one down the page and not in a slideshow. I've put the images in the database giving each one their own column. Is this wrong? How can I make the images be a slideshow. Thanks for helping.

<div id="lodgeGallery" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#lodgeGalleryl" data-slide-to="0" class="active"></li>
<li data-target="#lodgeGalleryl" data-slide-to="1"></li>
<li data-target="#lodgeGalleryl" data-slide-to="2"></li>
<li data-target="#lodgeGalleryl" data-slide-to="3"></li>
<li data-target="#lodgeGalleryl" data-slide-to="4"></li>
<li data-target="#lodgeGalleryl" data-slide-to="5"></li>
<li data-target="#lodgeGalleryl" data-slide-to="6"></li>
<li data-target="#lodgeGalleryl" data-slide-to="7"></li>
<li data-target="#lodgeGalleryl" data-slide-to="8"></li>
<li data-target="#lodgeGalleryl" data-slide-to="9"></li>
<li data-target="#lodgeGalleryl" data-slide-to="10"></li>


</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">


<div class="item active">

      <?php

      //<img src="img/img1.jpg" alt="">
      echo "<img src='img/$galleryImg1'";
      ?>

</div>

<div class="item">
    <?php

      //<img src="img/img2.JPG" alt="">
      echo "<img src='img/$galleryImg2'";
      ?>
</div>

<div class="item">
    <?php

    //<img src="img/img3.png" alt="">
    echo "<img src='img/$galleryImg3'";

    ?>
    </div>

<div class="item">

    <?php

    //<img src="img/img4.png" alt="">
    echo "<img src='img/$galleryImg4'";

    ?>
   </div>

 <div class="item">
     <?php

     //<img src="img/img5.jpg" alt="">
     echo "<img src='img/$galleryImg5' ";

     ?>
   </div>

   <div class="item">
   <?php

   //<img src="img/img6.jpg" alt="">
   echo "<img src='img/$galleryImg6' ";

   ?>
  </div>

   <div class="item">
   <?php

   //<img src="img/img7.jpg" alt="">
   echo "<img src='img/$galleryImg7' ";

   ?>

</div>

   <div class="item">
   <?php

   //<img src="img/img8.jpg" alt="">
   echo "<img src='img/$galleryImg8'";

   ?>

</div>

   <div class="item">

   <?php

   //<img src="img/img9.jpg" alt="">
   echo "<img src='img/$galleryImg9' ";

   ?>

</div>

   <div class="item">

  <?php

  //<img src="img/img10.JPG" alt="">
  echo "<img src='img/$galleryImg10' ";

  ?>

</div>

   <div class="item">

 <?php

  //<img src="img/img11.jpg" alt="">
  echo "<img src='img/$galleryImg11' ";

            ?>
  </div>

  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#lodgeGallery" role="button" data-   slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#lodgeGallery" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>

Upvotes: 0

Views: 635

Answers (2)

Bradley Sweeten
Bradley Sweeten

Reputation: 11

For pulling the images from a database:

2 columns: RowID & ImageURL

select RowID, Image URL from db

$sql = ("SELECT RowID,ImageURL FROM db.dbo.table");
$res = odbc_exec($dbConn,$sql);

while ($images = odbc_fetch_array($res)){
    echo "<img src="img/".$images."'/>";
}

Upvotes: 0

Griseld Gerveni
Griseld Gerveni

Reputation: 482

Seeing your code, i think you have ne error in the syntax of how you echo the image from server. It should be "<img src ='img/'.$galleryImg1.'"

Upvotes: 1

Related Questions