I'm having a problem, I try to show on a bootstrap carousel the images of a directory, but it does not work because it puts them all as active items, and I do not find the error in my code. Someone to help me ...
<div id="imagenes" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<?php $path = 'images/art/'.$id;
if (file_exists($path)){
$directorio = opendir($path);
$i=1;
while (false !== ($archivo = readdir($directorio))){
if (!is_dir($archivo)){
if ($i=1){
echo "<div class='item active'><img src='images/art/$id/$archivo' style='max-width: 300px; max-height: 300px' /></div>";
} else {
echo "<div class='item'><img src='images/art/$id/$archivo' style='max-width: 300px; max-height: 300px' /></div>";
}
$i++;
}
}
} ?>
</div>
<a class="left item-control" href="#imagenes" data-slide="prev">
<i class="fa fa-angle-left"></i>
</a>
<a class="right item-control" href="#imagenes" data-slide="next">
<i class="fa fa-angle-right"></i>
</a>
</div>