简体   繁体   English

图像未加载到轮播中

[英]images not loading inside the carousel

i have a carousel on my website and wish to load images from database, although the carousel is working fine, but the images are not loading 我在我的网站上有一个轮播,并希望从数据库中加载图像,尽管该轮播工作正常,但图像未加载

Database View 数据库视图

    id    image1                   image2               image3
    1  carouselimage/image1  carouselimage/image1   carouselimage/image1

there wouldbe only one row in this table 该表中只有一行

code for carousel 轮播代码

 <?php
        require 'connection.php';
            echo "<header id='myCarousel' class='carousel slide'>";
                echo "<ol class='carousel-indicators'>";
                    echo "<li data-target='#myCarousel' data-slide-to='0' class='active'></li>";
                    echo "<li data-target='#myCarousel' data-slide-to='1'></li>";
                    echo "<li data-target='#myCarousel' data-slide-to='2'></li>";
                echo "</ol>";

                echo "<div class='carousel-inner'>";

                    $sql = "SELECT * FROM carousel_image ";

                    $result = mysqli_query($con, $sql);
                    if (mysqli_num_rows($result) > 0) 
                        {
                            while($row = mysqli_fetch_array($result)) 
                                {
                                    $image1=$row['image1'];
                                    $image2=$row['image2'];
                                    $image3=$row['image3'];

                                    echo "<div class='item active'>";
                                        echo "<div class='fill' style='background-image:url('http://example.com/carouselimage/" .$image1."\' height=\'500\' width=\'2000\'/);></div>";
                                    echo "</div>";

                                    echo "<div class='item'>";
                                        echo "<div class='fill' style='background-image:url('http://example.com/carouselimage/" .$image2."\' height=\'500\' width=\'2000\'/);></div>";
                                    echo "</div>";

                                    echo "<div class='item'>";
                                        echo "<div class='fill' style='background-image:url('http://example.com/carouselimage/" .$image3."\' height=\'500\' width=\'2000\'/);></div>";
                                    echo "</div>";
                                }
                        }
                echo "</div>";  

                echo "<a class='left carousel-control' href='#myCarousel' data-slide='prev'>";
                    echo "<span class='icon-prev'></span>";
                echo "</a>";
                echo "<a class='right carousel-control' href='#myCarousel' data-slide='next'>";
                    echo "<span class='icon-next'></span>";
                echo "</a>";
            echo "</header>";

            mysqli_close($con); 
    ?>

would appreciate if someone could help me with the code 如果有人可以帮助我提供代码,我将不胜感激

Your problem is probably not the SQL, but this line of PHP/HTML and CSS: 您的问题可能不是SQL,而是PHP / HTML和CSS的这一行:

echo "<div class='fill' style='background-image:url('http://example.com/carouselimage/" .$image1."\' height=\'500\' width=\'2000\'/);></div>";
                              ^ a ' opens style and ^ this ' closes style again

So you gotta fix your quotes, and as well: 因此,您必须修正报价,以及:

echo "<div style='[..]height=\'500\' width=\'2000\'/);></div>";
           ^^^^^^^^^^^^^^^^^ height/width within style="" shouldn't have = or a quote

Honestly this is basic HTML/CSS, so I would advise you to look at w3schools to learn how to prevent these mistakes. 老实说,这是基本的HTML / CSS,所以我建议您去看看w3schools,以学习如何防止这些错误。 It should be something like this: 应该是这样的:

echo '<div class="fill" style="background-image:url(http://example.com/carouselimage/' . $image1 . ');height:500px;width:2000px;"></div>';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM