我有一个使用php / html的照片库 所以,不使用数据库,工作得很好!使用此代码的照片和缩略图:
<div id="js-grid-slider-thumbnail" class="cbp">
<div class="cbp-item">
<div class="cbp-caption">
<div class="cbp-caption-defaultWrap">
<img src="img/header/header_03.jpg" alt="">
</div>
</div>
</div><!-- end item -->
<div class="cbp-item">
<div class="cbp-caption">
<div class="cbp-caption-defaultWrap">
<img src="img/header/header_04.jpg" alt="">
</div>
</div>
</div><!-- end item -->
<div class="cbp-item">
<div class="cbp-caption">
<div class="cbp-caption-defaultWrap">
<img src="img/header/header_05.jpg" alt="">
</div>
</div>
</div><!-- end item -->
</div><!-- end js-grid-slider-thumbnail -->
<div id="js-pagination-slider">
<div class="cbp-pagination-item cbp-pagination-active">
<img src="img/header/header_03.jpg" alt="">
</div>
<div class="cbp-pagination-item">
<img src="img/header/header_04.jpg" alt="">
</div>
<div class="cbp-pagination-item">
<img src="img/header/header_05.jpg" alt="">
</div>
</div><!-- end js-pagination-slider -->
但我想使用数据库而我正在尝试使用Select SQL,从id区域spring
的数据库中选择所有照片但是我看到照片和缩略图,不起作用
<?php
$sql2 = mysql_query("select * from Photos where photoid='spring'");
while ($row = mysql_fetch_array($sql2)) { ?><div id="js-grid-slider-thumbnail" class="cbp">
<div class="cbp-item">
<div class="cbp-caption">
<div class="cbp-caption-defaultWrap">
<img src="img/portfolio/<? echo $row['link'];?>" alt="">
</div>
</div>
</div><!-- end item -->
</div><!-- end js-grid-slider-thumbnail --><?}?>
<div id="js-pagination-slider">
<?php while ($row2 = mysql_fetch_array($sql2)) { ?>
<div class="cbp-pagination-item cbp-pagination-active">
<img src="img/portfolio/<? echo $row2['link'];?>" alt="">
</div>
<?}?>
</div><!-- end js-pagination-slider -->
问题: 照片工作正常 但我没有看到缩略图 有人可以帮帮我吗? 感谢
答案 0 :(得分:0)
将包装器放在外部或while循环中作为JS的id必须只有一次像下面那样用于循环外部使用的分页,所以只显示一次希望有效!
<?php
$sql2 = mysql_query("select * from Photos where photoid='spring'"); ?>
<div id="js-grid-slider-thumbnail" class="cbp">
<?php
while ($row = mysql_fetch_array($sql2)) { ?>
<div class="cbp-item">
<div class="cbp-caption">
<div class="cbp-caption-defaultWrap">
<img src="img/portfolio/<? echo $row['link'];?>" alt="">
</div>
</div>
</div><!-- end item -->
</div><!-- end js-grid-slider-thumbnail --><?}?>
<div id="js-pagination-slider">
<?php while ($row2 = mysql_fetch_array($sql2)) { ?>
<img src="img/portfolio/<? echo $row2['link'];?>" alt="">
</div>
<?}?>
</div><!-- end js-pagination-slider -->
&#13;