嘗試在codeigniter的foreach循環中顯示來自數據庫的輪播圖像。下面的代碼一次顯示所有圖像。我怎樣才能一個一個地顯示滑塊內的圖像?另外下一個和上一個按鈕不起作用?循環顯示圖像從db到bootstrap輪播
<div id="myCarousel" class="carousel slide carousel-fade" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<?php $i = 1; ?>
<?php $item_class = ($i == 1) ? 'item active' : 'item'; ?>
<div class="<?php echo $item_class; ?>">=
<a href="#">
<?php foreach ($m->result() as $row) :
$Player=$row->image;
echo "<img src='http://opunletter.com/" . $Player . "'";
?>
</a>
</div>
<?php $i++; ?>
<?php endforeach; ?>
</div>
<a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div><!-- /.carousel -->
您的訂購清單應該與您在其下面構建div的方式相同,因爲它從0開始;你的櫃檯也應該從零開始。 – ahmad