Hi guys, I am trying to get thumbnails out of a directory and display them, but for some reason it is not working and I am lost as to why as the variable I am using works just fine earlier in the code. I am about to have a mental breakdown over this.
My image directory is set up like this:
/items/company/item_name/*images go here ie: A_full, A_thumb, B_full, B_thumb.
First I am getting the items information for display (note, I am sanitizing everything, just shortening this example):
if (isset($_GET['itemurl'])) {
$item-url = $_GET['itemurl'];
$get_item = mysqli_query($link, "SELECT items.*, company.company-name FROM items INNER JOIN company ON items.company-id=company.id WHERE items.item_url = '$item-url'");
$row = mysqli_fetch_assoc($get_item);
if (!$row) {
echo 'Error.';
exit();
}
$image_directory = "/items/$item-url/"; // for this example, $item-url = company-name/item-name-one/
// I also set a bunch of other variables for item display here
Then I display the item:
$item-thumb = "$image_directory" . "top.jpg";
echo "<div><img src='$itemthumb'></div>";
// bunch more item stats here etc, then lastly:
echo '<div>';
$images = glob($image_directory."*_thumb*");
if (!$images) {
echo 'No images found.';
}
else {
foreach ($images as $image) {
$full = str_replace('thumb','full',$image);
echo '<a href="'.$full.'" target="_blank"><img src="'.$image.'"></a>';
}
}
echo '</div>';
Now what doesn’t make sense to me is…the thumbnail I have linked to using the $image_directory variable at the top of the ‘display the item’ portion of my code displays correctly…it’s only the thumbs at the bottom that aren’t showing up (I get the ‘No images found’ error I have set, yet the variable is the same…and all of those images are in the same directory…
Any help on this would be appreciated more than I can say as I’m losing my mind a bit, not to mention sleep.