stublackett Posted July 29, 2008 Share Posted July 29, 2008 Hi, I've got images uploaded into a Database What I'd like to know is how you use PHP to manipulate showing "No Image" or something of that sort into a web page The user can add 2 images to a page, But the usual scenario is a second image doesnt get uploaded, So its leaving me with the IE [x] what I'd like to do is replace that with a possible new image Is there any PHP Tutorials / Classes or anything of that sort you can point me towards to help me achieve this? Cheers Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/ Share on other sites More sharing options...
Xurion Posted July 29, 2008 Share Posted July 29, 2008 I'm not sure what you're asking. Do you want to show a 'No Image' image if there isn't one specified in the database? Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602552 Share on other sites More sharing options...
stublackett Posted July 29, 2008 Author Share Posted July 29, 2008 Thats right, Yeah! A "No Image" image is what I want to display Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602584 Share on other sites More sharing options...
Xurion Posted July 29, 2008 Share Posted July 29, 2008 First you'll need to check if the image exists. If it does, display it, and if not, display a generic non-image. if(file_exists('images/your_directory/your_image.jpg')){ echo '<img src="images/your_directory/your_image.jpg" />'; }else{ echo '<img src="images/your_directory/non_image.jpg" />'; } Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602614 Share on other sites More sharing options...
stublackett Posted July 29, 2008 Author Share Posted July 29, 2008 First you'll need to check if the image exists. If it does, display it, and if not, display a generic non-image. if(file_exists('images/your_directory/your_image.jpg')){ echo '<img src="images/your_directory/your_image.jpg" />'; }else{ echo '<img src="images/your_directory/non_image.jpg" />'; } Thank you Xurion I suppose the same logic works for an MySQL Database and set Variables ? Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602630 Share on other sites More sharing options...
Xurion Posted July 29, 2008 Share Posted July 29, 2008 Yeah, in simplest explanation - it is only an if statement. Link to comment https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.