Jump to content

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


fubarur

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...
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.