I have page where I display thumbnails of different image albums/categories and I try to make it when user click on the thumb to open modal with all images loaded from this category. The problem is that is seems I can't understand it very well how exactly will happen this. Now I have all the albums on the page but the modal is opened only when I click on last thumb. This is what I have so far:
<?php
require_once 'misc/database.php';
echo '<section id="portfolio" class="grid">';
foreach($pdo->query("SELECT * FROM albums ORDER BY album_id") as $row)
{
echo '
<figure class="effect-portfolio wow fadeIn"> <!-- Portfolio 3 -->
<img src="'.$row['album_image'].'" alt="03_img"/> <!-- Your image here -->
<figcaption> <!-- Caption -->
<h2>'.$row['album_name'].'</h2>
<a href="#portfolioModal2-'.$row['album_id'].'" class="portfolio-link" data-toggle="modal"></a>
</figcaption> <!-- End caption -->
</figure> <!-- End portfolio 3 --> ';
}
echo '</section>
<div class="portfolio-modal modal fade" id="portfolioModal2-'.$row['album_id'].'" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div><div class="container">
<div class="row">';
if(isset($row['album_id'])){
$album_id = $row['album_id'];
$query2 = $pdo->query("SELECT * FROM images WHERE image_album = $album_id ORDER BY image_id DESC ");
foreach ($query2 as $row2) {
echo '<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<div class="item active">
<img src="img/'.$row2['image_path'].'" alt="">
</div>
</div>
</div>';
}
}
echo '</div>
</div></div></div> ';
Database::disconnect();
?>