Jump to content

Archived

This topic is now archived and is closed to further replies.

fubarur

(Resolved) PHP script to look in folder for image and display

Recommended Posts

Hello,

I've done some searching around the forums and can't seem to find anything to fit my need.

What I'm trying to do:
Page that displays a certian set of stores by pulling out of the database and displays an image next to each store listing.

I have the script all setup and is looking in a folder /images/dealers/ and looks for a image with dealer_id and displays it fine. but if there is no image for that dealer instead of displaying a broken image havng no image would be better.

[code]
    <td width="50%" align="right">

    <img border="1" src="<?=Environment::webroot()?>/images/dealers/<?=$row['id']?><?=$ext?>" />
    </td>[/code]



Like I said it displays images fine but I don't want it to display broken images if it can't find and image.

Any help is appreciated!

Thanks...

Share this post


Link to post
Share on other sites
I figured it out

[code]                            <td width="50%" align="right" class="font-smx">
<?php
if (file_exists('/var/www/html/images/dealers/' . $row['id'] . $dthumb)):
?>
                              <img border="1" src="<?=Environment::webroot()?>/images/dealers/<?=$row['id']?><?=$dthumb?>" />
<?php
endif;
?>
                            </td>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.