使用Bootstrap Carousel,如何打印php输出?

时间:2019-03-02 01:37:13

标签: php html

我正在尝试从phpmyadmin数据库中打印出图片,但是以启动轮播形式,这是我的工作:

`

    $sql = "SELECT * FROM sneakers_catalogue WHERE Item_ID=$id";
    $result = $conn->query($sql);

        if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {


            echo $row["Brand"];
            echo " ";
            echo " Sneaker: " . $row['Sneaker_Name'];               
            echo " ";
            echo " Description: " . $row['Description'];
            $pic = $row["Picture"];
            $pic2 = $row["Picture_2"];              
            echo "</br> <img class = 'thumbnail' src='$pic'/>";
            echo "<img class = 'thumbnail' src='$pic2'/>";              
            echo "</div>";
        }
        } else {
            echo "0 results";
        }           
    $conn->close();
?>

    <div id="myCarousel" class="carousel slide" data-ride="carousel" style="float: left">

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
        <div class="item active">
            <img src="$pic" style="width: 570px; height: 400px">
        </div>

        <div class="item">
            <img src="images/Jordan-1Mid-Red2.jpg" alt="Jordan 1" style="width: 570px; height: 400px">
        </div>

    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
        <span class="sr-only">Next</span>
    </a>

</div>    `

第二张图像可以工作,但是那是因为它直接来自我的文件夹,但是第一张图像是来自数据库的,我不确定如何打印出来。

谢谢。

0 个答案:

没有答案