This is my code
<?php
$query= "SELECT album_name FROM gallery group by album_name order by MIN(date_time)";
$stmt = $connection->prepare($query);
$stmt->execute();
$result=$stmt->get_result();
while ($row = $result->fetch_array(MYSQLI_BOTH)) { //First while loop
$album_names =htmlspecialchars($row['album_name']);`
?>
<ul>
<li data-tags="<?php echo $album_names ?>">
Till this point everything works fine , It shows me the names of all the albums that are there in my db .
What I want to do next is I want it to show all the pics which belong to $album_names so I wrote this code after above code
// Code continues
<?php
$query2= "SELECT imgage_path,resized_path FROM gallery WHERE album=?";
$stmt = $connection->prepare($query2);
$stmt->bind_param("s",$album_names);
$stmt->execute();
$result2=$stmt->get_result();
while ($row2 = $result2->fetch_array(MYSQLI_BOTH)) { //Second while loop
$thumbnail_path = =htmlspecialchars($row2['resized_path']);
$image_path =htmlspecialchars($row2['image_path']);
?>
<a href="<?php echo $image_path ?>">
<img src="<?php echo $thumbnail_path ?>" alt="Illustration" />
</a>
</li>
</ul>
<?php
} //Second While loop ends
} //First While loop ends
?>
Problem is that it only shows me the first result of $image_path and $thumbnail_path but I want it to show all the image paths belonging to that particular album.
Hope I have cleared my question .
album_name- why not use the outer query to return all the information you want and remove the inner query?