Jump to content


Photo

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


  • Please log in to reply
1 reply to this topic

#1 fubarur

fubarur
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 18 October 2006 - 09:49 PM

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.

    <td width="50%" align="right"> 

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



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...

#2 fubarur

fubarur
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 18 October 2006 - 10:42 PM

I figured it out

                            <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>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users