从数据库中检索数据时尝试增加标记ID

时间:2017-07-16 08:34:42

标签: increment

我能够使用foreach从mysql中检索数据但是想要在jquery轮播中显示值,问题是它只显示轮播中3个值中的第一个值,因为它只是看到了第一个身份证。我的javascript有3个ID迭代,我想显示3条记录。请查看我的代码并告知我是否做错了。

感谢。

PHP代码:

<?php
foreach($artists as $artist_s): 
$c = 1;
?>
<div class="holder-inner artist" id="<?php echo 'artist'.$c; ?>">
<div class="avatar-holder">
<img class="avatar" id="<?php echo 'avatar'.$c; ?>" src="<?php echo base_url();?>/public/img/<?php echo $artist_s['media_img'];?>">
</div>
<div class="text-holder">
<h2 class="heading" id="<?php echo 'heading'.$c;?>"><?php echo $artist_s['artist'];?></h2>
<h4 class="description" id="<?php echo 'description'.$c;?>"><?php echo word_limiter($artist_s['entry_text'], 50);?></h4>
</div>
</div>
<?php $c++;?>
<?php endforeach; ?>
</div>

Javascript代码:

<script type="text/javascript">
var tl = new TimelineMax({repeat:-1, repeatDelay:0.1});
tl.fromTo(["#artist1", "#avatar1"], 1, {opacity:0, x:"100%"}, {opacity:1, x:"-50%"})
.fromTo("#heading1", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.fromTo("#description1", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.to("#artist1", 0.5, {opacity:0}, "+=3")
.fromTo(["#artist2", "#avatar2"], 1, {opacity:0, x:"100%"}, {opacity:1, x:"-50%"})
.fromTo("#heading2", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.fromTo("#description2", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.to("#artist2", 0.5, {opacity:0}, "+=3")

.fromTo(["#artist3", "#avatar3"], 1, {opacity:0, x:"100%"}, {opacity:1, x:"-50%"})
.fromTo("#heading3", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.fromTo("#description3", 0.5, {opacity:0, x:10}, {opacity:1, x:0})
.to("#artist3", 0.5, {opacity:0}, "+=3")


</script>

0 个答案:

没有答案