I am fairly new to php and am having some trouble trying to get my images to populate correctly from my database. Any help would be appreciated.
Below is my current code. It is currently returning my default image and not my product image if in the database.
<?php
$query = "SELECT products.giftID, products.gift_name, products.price, products.short_description, product_image.picture FROM products LEFT JOIN product_image ON product_image.giftID='products.giftID' AND products.vendorID='1'";
$result = mysql_query($query) or die ("Database access failed:".mysql_error());
while($row = mysql_fetch_assoc($result)) {
if($row['picture'] == '') {
echo "<img src=product_img/image_coming_soon.jpg>";
} else {
echo "<img src='".$row['picture'] ."'>";
}
}
?>
Formatting the query for readability:
SELECT products.giftID, products.gift_name, products.price,
products.short_description,
product_image.picture
FROM products
LEFT JOIN product_image ON product_image.giftID='products.giftID'
AND products.vendorID='1'