I'm new to php and am having trouble retrieving an image for display in a page. The image path is stored in a mysqli database under the column image. My code is listed below. Any help would be appreciated.
footwear.php
<img class="product-item_image" src="getImage.php?id=1" alt="Product">
getImage.php
<?php
$id = $_GET['id'];
$link = mysqli_connect("localhost","root","","dbname","3307");
$sql = "SELECT image FROM dbname.product_catalog WHERE id='$id'";
$result = mysqli_query($link,$sql);
$row = mysqli_fetch_assoc($result);
$image = $row['image'];
$image_src = $image;
mysqli_close($link);
echo "<img src='$image' >";
?>
when I navigate to getImage.php?id=1 the image is successfully displaying. However, when I'm viewing footwear.php the image is broken. I know there is something fundamentally wrong with my code, but I don't know what the next step is to get this to function as I'm intending.
Note, the Mysql database column holds the value "amour-03-bsat.jpg", but I'm unsure of how to get this value into footwear.php. I'm open to any other method of getting my image to display as well.
Thanks!