cheeseus Posted April 23, 2007 Share Posted April 23, 2007 Hello, I am trying to write a check for each item in a news database - if there is an image in the 'image' row, display it, if there isn't an image, display an empty.gif instead. This is how far I got, but I'm new to php, so don't laugh too much $image=mysql_result($godinass,$i,"image"); if(!isset($_GET['image'])) { $imageurl = "http://mysite.com/features/".$image; }else{ $imageurl = "http://mysite.com/images/empty.gif"; } and then, further down, the script echoes the results: echo '<div id=right_floated><img src=".$imageurl." border=1></div>' What I've noticed is that if the statement is "!isset" the image is displayed (if there is one), if not, the X for missing image appears, while if I change the statement to "isset" the empty.gif is displayed whether or not there is an image for this particular id. Thanks in advance to anyone who'd bother! Quote Link to comment Share on other sites More sharing options...
Mutley Posted April 23, 2007 Share Posted April 23, 2007 Try: <?php $image=mysql_result($godinass,$i,"image"); $imgcheck = $_GET['image']; if(empty($imgcheck)) { $imageurl = "http://mysite.com/images/empty.gif"; }else{ $imageurl = "http://mysite.com/features/".$image; } ?> Quote Link to comment Share on other sites More sharing options...
cheeseus Posted April 23, 2007 Author Share Posted April 23, 2007 Thanks a lot! When I inserted this piece of code in the page source, it worked at first and the image appeared if there was one, or the blank one if there wasn't. But then, only the empty image started appearing whether or not there is an image or not I have no idea why I made no changes to the code other than type in the website address , hm... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.