duduwudu Posted August 8, 2007 Share Posted August 8, 2007 Hello, I'm sure this is very simple, but as a bit of a beginner I would appreciate any help. I have a page that is pulling information from a database of local businesses. One of the columns is a URL and on the page I have a link 'Visit website' and the url from the database is the link. However, not all the entries in my database have a website and are null. So this is creating the problem that some of my listing have a link that says visit website, that go nowhere. This is the code i am using: <a href="<?php echo $row_Businesses['website']; ?>" target="_blank">Visit Website</a> What I would like is, if the 'website' column is null then the visit website link doesn't appear but if there is an entry for the 'website' column then there is a link saying visit website that has the 'website' column entry as the link (like above). Any help that'll help me understand or get this done would make me a very happy boy Cheers Quote Link to comment https://forums.phpfreaks.com/topic/63886-solved-hiding-static-content-if-column-is-null-should-be-simple/ Share on other sites More sharing options...
hostfreak Posted August 8, 2007 Share Posted August 8, 2007 <?php $txt = ($row_Businesses['website']) ? "Visit Website" : ""; ?> <a href="<?php echo $row_Businesses['website']; ?>" target="_blank"><?php echo "$txt"; ?></a> Quote Link to comment https://forums.phpfreaks.com/topic/63886-solved-hiding-static-content-if-column-is-null-should-be-simple/#findComment-318442 Share on other sites More sharing options...
poizn Posted August 8, 2007 Share Posted August 8, 2007 Try something like this if($website != "") { <a href="<?php echo $row_Businesses['website']; ?>" target="_blank">Visit Website</a> } Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/63886-solved-hiding-static-content-if-column-is-null-should-be-simple/#findComment-318448 Share on other sites More sharing options...
duduwudu Posted August 8, 2007 Author Share Posted August 8, 2007 Thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/63886-solved-hiding-static-content-if-column-is-null-should-be-simple/#findComment-318449 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.