是否可以添加来自数据库的jQuery滑块?

时间:2014-11-04 05:49:14

标签: php mysql

我试图让jQuery滑块来自数据库,以便像HTML一样显示它。

HTML中的幻灯片:http://puu.sh/cCD3x/7421da5d3a.jpg

我的数据库:http://puu.sh/cCD5w/fe9465a903.png

这是我的代码:

<div class="slider_bg">
<div class="wrap">
<div class="wrapper">
    <div class="slider">
    <!-- #camera_wrap_1 -->
    <div class="fluid_container">
        <div class="camera_wrap camera_azure_skin" id="camera_wrap_1">
            <div data-thumb="../images/thumbs/slider1.jpg" data-src="../images/slider/slider1.jpg">
            </div>
            <div data-thumb="../images/thumbs/slider2.jpg" data-src="../images/slider/slider2.jpg">
            </div>
            <div data-thumb="../images/thumbs/slider3.jpg" data-src="../images/slider/slider3.jpg">
            </div>
            <div data-thumb="../images/thumbs/slider4.jpg" data-src="../images/slider/slider4.jpg">
            </div>            
             </div><!-- #camera_wrap_1 -->
         <div class="clear"></div>
    </div>
    <!-- end #camera_wrap_1 -->
    <div class="clear"></div>
    </div>
</div>
</div>
</div>

我认为代码的工作原理:

                                                                                        <?php
 $sql = "SELECT image FROM product where productID=2";
 $result = mysql_query($sql) or die(mysql_error($connection));
 while ($row = mysql_fetch_array($result)) //display the results
 {
 echo "<a href='../images/".$row['image']."'><img src='../images/".$row['image']."' /></a>"; 
 }
?>

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

 <?PHP
     $sql = "SELECT image FROM product where productID=2";
     $result = mysql_query($sql) or die(mysql_error($connection));
?>  



<div class="slider_bg">
    <div class="wrap">
    <div class="wrapper">
        <div class="slider">
        <!-- #camera_wrap_1 -->
        <div class="fluid_container">
            <div class="camera_wrap camera_azure_skin" id="camera_wrap_1">
                <?PHP while($row = mysql_fetch_array($result)): //display the results ?>
                        <div data-thumb="../images/thumbs/<?PHP echo $row['image']; ?>" data-src="../images/slider/<?PHP echo $row['image']; ?>">
                         </div>
                <?PHP endwhile; ?>          

            </div><!-- #camera_wrap_1 -->
            <div class="clear"></div>
        </div>
        <!-- end #camera_wrap_1 -->
        <div class="clear"></div>
        </div>
    </div>
    </div>
    </div>