duduwudu Posted August 8, 2007 Share Posted August 8, 2007 Hello, I'm sure this is very simple, but I'm just getting started with php and mysql and was wandering if someone could help me with a snipped of code. I have a page that displays information from my database. One of the items it displays is an image. like this: <img src="<?php echo $row_Businesses['logo_url']; ?>" alt="<?php echo $row_Businesses['name']; ?>" width="100" height="100" border="1" /> Now, not all of the rows in my database have an entry for 'logo_url' and are null. I would like it so that if 'logo_url' is null it will instead show an alternative image called nologo.gif I imagine it would be along the lines of if 'logo_url' = null show nologo.gif else show <?php echo $row_Businesses['logo_url']; ?>. Any help would make me a very happy boy, Cheers Quote Link to comment Share on other sites More sharing options...
pranav_kavi Posted August 8, 2007 Share Posted August 8, 2007 I hope tis helps, <img src="<?php $img = (strlen($row_Businesses['logo_url'])<>0)?$row_Businesses['logo_url']:"nologo.gif"; echo $img; ?>" alt="<?php echo $row_Businesses['name']; ?>" width="100" height="100" border="1" /> Quote Link to comment Share on other sites More sharing options...
duduwudu Posted August 8, 2007 Author Share Posted August 8, 2007 Works a dream. Thankyou very much Quote Link to comment Share on other sites More sharing options...
pranav_kavi Posted August 8, 2007 Share Posted August 8, 2007 COOL...ur welcome...i suppose u ll ve to modify d thread to 'SOLVED' status then.... 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.