视频轮播使用bootstrap作为第一个活动项目,该怎么办?

时间:2014-07-14 13:23:09

标签: php mysql twitter-bootstrap carousel

我需要帮助才能使用php mysql动态获取视频, 我需要帮助指标:

<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>

和类“活动项目”

以下代码我使用了

<?php
$sql = "SELECT aaa, ddd, fff, ggg FROM table ASC LIMIT 0, 20";
$result = mysql_query($sql);
?>
<h4>Upcoming Films:</h4>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
  </ol>
   <div class="carousel-inner">
<?php
while($row = mysql_fetch_array($result))
{
$aaa=$row['aaa'];
$ddd=$row['ddd'];
$fff=$row['fff'];
$video=$row['video'];
?>
  <!-- Wrapper for slides -->
    <div class="item">
      <iframe width="750" height="422" src="http://www.youtube.com/embed/<?php echo"$video";?>" frameborder="0" allowfullscreen></iframe>
    </div>

<?php
}
?>
  </div>

    <!-- Controls -->
    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
</div>
<?php
mysql_free_result($result);
mysql_close();
?>

1 个答案:

答案 0 :(得分:0)

<div class=
                                      <?php
                                        echo '"';
                                        echo 'item '; 
                                        if ($i == 1) {
                                          echo 'active';
                                        }

                                        echo '"';

                                        ?>>

这里有内容循环

然后

<?php

                                    $i++;


                                    }
  ?>