xtiancjs Posted April 21, 2006 Share Posted April 21, 2006 Hi , am having a little trouble with the following:I have a link that contains a url like this:homepage:<a href="<?php echo $row_bprofile['broker_url']; ?>" target="_blank"> click here</a>What I want to do is, if there is a value in the db for the url , display the linkif there is no url value just leave the space empty. i tried <?php $url1 = $row_bprofile['broker_url']; if($url1 = "not null") { echo 'homepage:<a href="<?php echo $row_bprofile['broker_url']; ?>" target="_blank"> click here</a>' ; } else {echo ;} ?>I got lots of errorsany ideas?xtian Quote Link to comment https://forums.phpfreaks.com/topic/8063-if-else-syntax-help/ Share on other sites More sharing options...
wildteen88 Posted April 21, 2006 Share Posted April 21, 2006 Change this:[code]<?php $url1 = $row_bprofile['broker_url'];if($url1 = "not null") { echo 'homepage:<a href="<?php echo $row_bprofile['broker_url']; ?>" target="_blank"> click here</a>'; }else {echo;} ?>[/code]to[code]<?php$url1 = $row_bprofile['broker_url'];if($url1 != "" && strlen($url) >= 6){ echo "homepage: <a href=\"" . $row_bprofile['broker_url'] . "\" target=\"_blank\">click here</a>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8063-if-else-syntax-help/#findComment-29400 Share on other sites More sharing options...
xtiancjs Posted April 21, 2006 Author Share Posted April 21, 2006 [!--quoteo(post=367264:date=Apr 21 2006, 02:30 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 21 2006, 02:30 PM) [snapback]367264[/snapback][/div][div class=\'quotemain\'][!--quotec--]Change this:[code]<?php $url1 = $row_bprofile['broker_url'];if($url1 = "not null") { echo 'homepage:<a href="<?php echo $row_bprofile['broker_url']; ?>" target="_blank"> click here</a>'; }else {echo;} ?>[/code]to[code]<?php$url1 = $row_bprofile['broker_url'];if($url1 != "" && strlen($url) >= 6){ echo "homepage: <a href=\"" . $row_bprofile['broker_url'] . "\" target=\"_blank\">click here</a>";}?>[/code][/quote]thanks for replying guru, what happenned was the link doesn't show in any situation, will keep trying, if you can think of anything else cool, if not peace Quote Link to comment https://forums.phpfreaks.com/topic/8063-if-else-syntax-help/#findComment-29492 Share on other sites More sharing options...
Orio Posted April 22, 2006 Share Posted April 22, 2006 Here:[code]<?php$url1 = $row_bprofile['broker_url'];if(!empty($url1)){ ?>homepage: <a href="<?php echo($url1); ?>" target="_blank"> click here</a><?php } ?>[/code]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/8063-if-else-syntax-help/#findComment-29565 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.