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 Link to comment https://forums.phpfreaks.com/topic/63877-solved-a-simple-if-null-question-i-hope/ 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" /> Link to comment https://forums.phpfreaks.com/topic/63877-solved-a-simple-if-null-question-i-hope/#findComment-318393 Share on other sites More sharing options...
duduwudu Posted August 8, 2007 Author Share Posted August 8, 2007 Works a dream. Thankyou very much Link to comment https://forums.phpfreaks.com/topic/63877-solved-a-simple-if-null-question-i-hope/#findComment-318409 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.... Link to comment https://forums.phpfreaks.com/topic/63877-solved-a-simple-if-null-question-i-hope/#findComment-318411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.