0

I have a photo gallery using php/html So, Without using database, work great! with photos and thumbnails using this code:

<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 -->

But I want to use database and I'm trying to use Select SQL, to select all photos from database that id area spring however I see the photos and thumbnails, don't work

<?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 -->

Problem: Photos work fine But I don't see thumbnails Anyone could help me? thanks

alexbt
  • 16,415
  • 6
  • 78
  • 87
  • Please don't do `` but do ` – node_modules Apr 18 '16 at 13:53
  • `$sql2 = mysql_query("select * from Photos where photoid='spring');` you forgot a double quote at the end. Also, you shoud read and adapt to [this](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Ekin Apr 18 '16 at 13:53
  • Thanks! Still have the problem, thumbnails don't show. I think the 2 while are not correct – Joana Rodrigues Apr 18 '16 at 14:19
  • Please check this link (final page, have thumbnail gallery) that I want to use MySql Select http://diamondcreative.net/themes/ada/v1.0/components-slideshows.html – Joana Rodrigues Apr 18 '16 at 15:03

1 Answers1

0

put wrapper outside or while loop as id for JS have to only once like below same for pagination used outside of loop so only show once hope that works !

<?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 -->
  • Please check this link (final page, have thumbnail gallery) that I want to use MySql Select http://diamondcreative.net/themes/ada/v1.0/components-slideshows.html – Joana Rodrigues Apr 18 '16 at 15:03