作者:mobiledu2502897737 | 来源:互联网 | 2023-08-01 10:44
我是codeigniter的新手,我不知道如何在codeigniter中显示轮播滑块
这是代码,实际上我知道错误是什么,但我不知道如何纠正它,即,在第一次执行时,分类必须是活动项目,并且在第一次执行之后,该类只需要是项目.
解决方法:
如果您确定问题只是第一个元素的“活动”类,那么您可以在foreach中执行以下操作:
$counter = 0;
//add a counter and check its value in your div.
//If it's 0, echo active, otherwise nothing.
//In the end of your loop, the counter increases so it won't be 0 again
foreach ($testimonials as $t) {
//next div will echo "active", if the $counter==0
?>
//increase the $counter, or set it another value in order not to echo "active" again for the next loops
$counter++;
}
?>