I'm trying to for loop the name of the photo in my database based on the username
<?php
$sql = "SELECT Name FROM images
WHERE user=$user";
$result = mysqli_query($con, $sql);
$name = $row['Name'];
// loop through the array of files and print them all in a list
for($index=0; $index < $indexCount; $index++) {
$extension = substr($dirArray[$index], -3);
if ($extension == 'jpg'){ // list only jpgs
echo '<div class="container22"><img class="testing2 img-thumbnail" src="users/userimg/'.$name.'' . $dirArray[$index] . '" alt="Image" /></div>';
}
}
?>