Jump to content

Archived

This topic is now archived and is closed to further replies.

Ansel_Tk1

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

Recommended Posts

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!

Share this post


Link to post
Share on other sites
The do an if statement like so:
[code]<?php if($row_rsalumni_database1['display_email'] == "Y") {
    echo $row_rsalumni_database1['address_email'];
} ?>[/code]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Then change this:
[code] <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>
[/code]
to:
[code]<?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>';
}
?>[/code]

Share this post


Link to post
Share on other sites
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 [i]link[/i] to not appear.

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

Share this post


Link to post
Share on other sites
Hmm not sure, would this work?


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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.