I have a default image set in the db in the column default_image. If the default_image = 1 I want it to display the default image and if default_image = 0 I want text to say no image available. How do I make sure only the default image is displayed. Here is what I am doing now and it just displays any image that has the same link_id.
the column media_link is the address to the image.
<?php if (!empty($row['default_image'])){
echo "<a href='http://localhost/images".$row['media_link']."'><img src='http://localhost/images".$row['media_link']."'/></a>";
}
else{
echo "<div align=\"center\">No image available</div>";
}?>
What do I do to make default_image "1" in the database display and nothing else? Thanks.
EDIT:
Here is another piece of code to show all the images for that link_id
if ($row['media_link']){
echo "<a href='http://localhost/t_images".$row['media_link']."'><img src='http://localhost/images".$row['media_link']."' /></a>";
}
else{
echo "<div align=\"center\">No images available</div>";
}
}
there is 6 images for this current id
When i echo the vardump on this page the correct image has this
string(1) "1"
while the other 5 images "non default"
show this string(1) "0"
I am not sure how to show only the correct default image where it goes on the page in my first code.
Does this info help at all?
EDIT AGAIN/FIXED:
I fixed it by adding ORDER BY default_image DESC to the end of my query. Don't know if that is the best thing to do but if anyone has any other suggestions i would be glad to hear them. Thanks everyone for all your help. You all gave great answers but in the end I just added the order by statement to my query and it works that way so I am happy.
Thanks!