Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在引导转盘中动态获取图像_Php_Jquery_Html_Loops_Twitter Bootstrap 3 - Fatal编程技术网

Php 如何在引导转盘中动态获取图像

Php 如何在引导转盘中动态获取图像,php,jquery,html,loops,twitter-bootstrap-3,Php,Jquery,Html,Loops,Twitter Bootstrap 3,我有一个自助旋转木马。我每行有两列。我希望我的图像来自数据库通过php 这是我的密码: <!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/full-slider.css"> <title>Unti

我有一个自助旋转木马。我每行有两列。我希望我的图像来自数据库通过php

这是我的密码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/full-slider.css">
<title>Untitled Document</title>
</head>

<body>

    <!-- Full Page Image Background Carousel Header -->
    <div id="myCarousel" class="carousel slide">
        <!-- Indicators -->
        <ol class="carousel-indicators">
            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
            <li data-target="#myCarousel" data-slide-to="1"></li>
        </ol>

        <!-- Wrapper for Slides -->
        <div class="carousel-inner">

         <?php 
            $query = mysql_query("select * from slides");
            while($row = mysql_fetcj_array($query)){
                $slides = $row['image'];
            ?>

            <div class="item active">

                <div class="row">
                  <div class="col-sm-6 col-xs-6"> <img src="<?php echo $slides ?>" alt=""/>
                    <div class="carousel-caption">This is a caption</div>
                  </div>

                   <div class="col-sm-6 col-xs-6"> <img src="http://placehold.it/260x180" alt=""/>
                     <div class="carousel-caption">This is a caption</div>
                   </div>

                 </div>
              </div>
              <?php } ?>


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

    </div>

    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>
    <!-- Script to Activate the Carousel -->
    <script>
    $('.carousel').carousel({
        interval: 5000 //changes the speed
    })
    </script>
</body>
</html>

无标题文件
  • “alt=”“/> 这是一个标题 这是一个标题 $('.carousel')。carousel({ 间隔:5000//改变速度 })

    现在的问题是,我有我的第一个div类(item active),其他的都是item。当我应用我的PHP时,每个div都会得到类(item active),我是如何在PHP中应用循环的,我的html没有干扰,我的滑块运行准确。

    无法评论,所以我会回答,对不起

    你的PHP在哪里?如果没有看到它,很难找出它的错误


    编辑:您的代码只定义了一个项。令人惊讶的是旋转木马居然能工作。您需要关闭div类似这样的内容吗?检查第一次迭代:

    <?php
        $isFirst = true;
    
        while (image loop) {
    
            // echoing image start...
            echo "<img ";
    
            // echoing stuff
            if ($isFirst) { 
                echo "class='active'"; 
            }
    
            // echoing the end of image
            echo " />";
    
            $isFirst = false;
        }
    ?>
    

    我不知道这样做是否正确。但我建议不要在循环中应用活动类。让DOM加载,然后使用JS(或Jquery)将其应用于类的第一个索引

    或者,您可以在PHP代码中为第一个索引添加if

    if(index==0){
      echo "<p class='item active'></p>";
    }else{  
     echo "<p class='item'></p>";
    
    if(索引==0){
    回显“

    ”; }否则{ 回声“

    ”;

    }

    你能将代码与你自己的php实现共享,这样我们就可以向你指出错误吗?因为现在这更像是要求我们从头开始做。
    mysql\u fetcj\u array
    这是一个打字错误,也是一个主要的错误,你没有检查错误。它是错误编写的,我的php运行良好。我只是有我的类问题at项目处于活动状态
    if(index==0){
      echo "<p class='item active'></p>";
    }else{  
     echo "<p class='item'></p>";