michaelyuen

Untitled

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