Jump to content


Photo

if else syntax help


  • Please log in to reply
3 replies to this topic

#1 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 21 April 2006 - 06:13 PM

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 link

if 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 errors



any ideas?

xtian

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 April 2006 - 06:30 PM

Change this:
<?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;} ?>
to
<?php

$url1 = $row_bprofile['broker_url'];

if($url1 != "" && strlen($url) >= 6)
{
    echo "homepage: <a href=\"" . $row_bprofile['broker_url'] . "\" target=\"_blank\">click here</a>";
}

?>


#3 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 21 April 2006 - 11:04 PM

[!--quoteo(post=367264:date=Apr 21 2006, 02:30 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 21 2006, 02:30 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Change this:
<?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;} ?>
to
<?php

$url1 = $row_bprofile['broker_url'];

if($url1 != "" && strlen($url) >= 6)
{
    echo "homepage: <a href=\"" . $row_bprofile['broker_url'] . "\" target=\"_blank\">click here</a>";
}

?>
[/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

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 April 2006 - 12:25 PM

Here:
<?php
$url1 = $row_bprofile['broker_url'];
if(!empty($url1)){ ?>
homepage: <a href="<?php echo($url1); ?>" target="_blank"> click here</a><?php } ?>

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users