doujun1495 2014-12-30 19:04
浏览 34
已采纳

将php添加到href bootstrap轮播

I am trying to do my bootstrap carousel dynamic, so I put php code in the href so the URL can be updated without need to get into the code, but when I put the php code it only shows the image who has the class=active, so if I do clic in "next" it appears the carousel without image, but if I do "Inspect element" in the browser the image is there.

Here is my code, Hope you can help me.

<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条回答 默认 最新

  • douzong5057 2014-12-30 19:45
    关注

    first verify if that file is a php file ; then change you code with this an try ;

    <?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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名