Only show item if relevant image exists
Posted: Mon Jul 24, 2006 7:24 am
Hi
I've got a MySQL db with up to 6 fields that contain paths to various images - sometimes those fields will be empty.
I'm currently showing the images like this:
But this produces empty image boxes and links when there's no appropriate image available.
I'm a bit stuck as to how to check that there's an image there first, then produce the relevant html around each link and image only if it exists, if that makes sense.
Any suggestions welcomed!
Thanks
I've got a MySQL db with up to 6 fields that contain paths to various images - sometimes those fields will be empty.
I'm currently showing the images like this:
Code: Select all
<? echo
'<ul id="vehicleimages">' .
'<li>' . '<a href="' . $large_image1 . '">' . '<img alt="" src="' . $small_image1 . '" />' . '</a>' . '</li>' .
'<li>' . '<a href="' . $large_image2 . '">' . '<img alt="" src="' . $small_image2 . '" />' . '</a>' . '</li>' .
'<li>' . '<a href="' . $large_image3 . '">' . '<img alt="" src="' . $small_image3 . '" />' . '</a>' . '</li>' .
'</ul>' ;I'm a bit stuck as to how to check that there's an image there first, then produce the relevant html around each link and image only if it exists, if that makes sense.
Any suggestions welcomed!
Thanks