Jump to content


Photo

link echo row from database = "value" from other row?


  • Please log in to reply
6 replies to this topic

#1 Ansel_Tk1

Ansel_Tk1
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 09 April 2006 - 04:51 AM

Hi all - I am creating a list that will use dynamic data from a table as link values. Is there a way for me to only create the link if the value from another field in the row = "Y"?

my link in the repeating region is:
<?php echo $row_rsalumni_database1['address_email']; ?>

but I only want the link if the value from $row_rsalumni_database1['display_email'] is "Y".

Hope this makes sense - any pointers?

Thanks!


#2 wildteen88

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

Posted 09 April 2006 - 11:40 AM

The do an if statement like so:
<?php if($row_rsalumni_database1['display_email'] == "Y") {
    echo $row_rsalumni_database1['address_email'];
} ?>


#3 Ansel_Tk1

Ansel_Tk1
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 09 April 2006 - 03:03 PM

Thank you so much for your help. One follow up question though - if the value of 'display_email' is not "Y", is there a way to prevent a blank link from coming up at all? As it is, if the value of display_email for the row = N than the link displayed on fullname is just 'mailto:'

I have tried putting the if before the <a href> tag but nada. Here is what I have:

<div align="left"><a href="mailto:<?php if($row_rsalumni_database1['display_email'] == "Y") {
echo $row_rsalumni_database1['address_email'];
} ?>"><?php echo KT_FormatForList($row_rsalumni_database1['fullname'], 20); ?></a></div>

thank you again for your help!

#4 wildteen88

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

Posted 09 April 2006 - 04:52 PM

Then change this:
<div align="left"><a href="mailto:<?php if($row_rsalumni_database1['display_email'] == "Y") {
echo $row_rsalumni_database1['address_email'];
} ?>"><?php echo KT_FormatForList($row_rsalumni_database1['fullname'], 20); ?></a></div>
to:
<?php
if($row_rsalumni_database1['display_email'] == "Y")
{
    echo '<div align="left"><a href="mailto:' . $row_rsalumni_database1['address_email'] . '">';
    echo KT_FormatForList($row_rsalumni_database1['fullname'], 20) . '</a></div>';
}
?>


#5 Ansel_Tk1

Ansel_Tk1
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 09 April 2006 - 06:17 PM

Hi - thank you again - I tried that, but if the value of display_email = "N" then the full_name value doesn't appear at all. I only want the link to not appear.

i reall appreciate your help - I am learning a lot here!



#6 nothix

nothix
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 09 April 2006 - 06:53 PM

Hmm not sure, would this work?


<?php
if($row_rsalumni_database1['display_email'] == "Y")
{
    echo '<a href="mailto:' . $row_rsalumni_database1['address_email'] . '">';
}
else
{
    echo "$row_rsalumni_database1['address_email']";
}
?>


#7 Ansel_Tk1

Ansel_Tk1
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 09 April 2006 - 10:41 PM

darn - tried that and didn't work. all i got was a blank screen. some php error i guess.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users