将php添加到href bootstrap轮播

时间:2014-12-30 19:04:49

标签: php html5 twitter-bootstrap

我正在尝试做我的bootstrap carousel动态,所以我把PHP代码放在href中,这样可以更新URL而无需进入代码,但是当我把php代码时它只显示有图像的人class = active,所以如果我在" next"它似乎没有图像的旋转木马,但如果我做"检查元素"在浏览器中,图像就在那里。

这是我的代码,希望你能帮助我。

<div id="ContieneCarousel">
<div id="myCarousel" class="carousel slide" Data-Interval="7000">
<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 = "1"></li>
</ol>

<div class="carousel-inner">
<div class="item active">
<?php echo "<a href='".$row['url']."'>" ?><img src="_admin/uploads/banner1.jpg"   title="MM1" alt="MM1" class="img-responsive" /><?php "</a>"; ?>
</div>

<div class="item">
<a href=""><img src="_admin/uploads/banner2.jpg" title="MM1" alt="MM1" class="img-responsive" /></a>
</div>

<div class="item">
<a href=""><img src="_admin/uploads/banner3.jpg" title="MM1" alt="MM1" class="img-responsive" /></a>
</div>

</div>

<a class="carousel-control left" href="#myCarousel" data-slide = "prev">
<span class="icon-prev"></span>
</a>

<a class="carousel-control right" href="#myCarousel" data-slide = "next">
<span class="icon-next"></span>
</a>

</div>
</div>

1 个答案:

答案 0 :(得分:0)

首先验证该文件是否是php文件; 然后尝试改变你的代码;

<?php 
$url = $row['url'] ;// test if URL is getted
if($url){
$html =  "<a href='$url'><img src='_admin/uploads/banner1.jpg'   title='MM1' alt='MM1' class='img-responsive' /></a>";
}else{
echo "URl not getted ";
}
?>
<div class="item active">
<?php echo $html ; ?>
</div>