Advertisement
michaelyuen

Untitled

Jan 7th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.         $consulta = "SELECT * FROM slider"; // remove LIMIT 1 to select all rows
  3.  
  4.         $cons = mysqli_query($conect_phpmyadmin,$consulta);
  5.         $i = 0; // set init value as 0
  6.         while ($rs = mysqli_fetch_array($cons)) {
  7.                 $id = $rs['id'];
  8.                 $imagem = "../uploads/".$rs['desc_img'];
  9.                 $active = ($i == 0) ? active : ''; // to set the first slide as active
  10. ?>
  11.         <div class="item <?= $active; ?>">
  12.             <img src="<?= $imagem; ?>">
  13.             <div class="carousel-caption">
  14.                  <div class="btn-group" role="group">
  15.                         <button type="button" class="btn btn-info"><h5>Replace this with your column value</h5></button>
  16.                 </div>
  17.             </div>
  18.         </div>
  19. <?php
  20.     $i++; // $i value will be incremental by 1
  21.  } ?>
  22.  </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement