Ansel_Tk1 Posted April 9, 2006 Share Posted April 9, 2006 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! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 9, 2006 Share Posted April 9, 2006 The do an if statement like so:[code]<?php if($row_rsalumni_database1['display_email'] == "Y") { echo $row_rsalumni_database1['address_email'];} ?>[/code] Quote Link to comment Share on other sites More sharing options...
Ansel_Tk1 Posted April 9, 2006 Author Share Posted April 9, 2006 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! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 9, 2006 Share Posted April 9, 2006 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]<?phpif($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] Quote Link to comment Share on other sites More sharing options...
Ansel_Tk1 Posted April 9, 2006 Author Share Posted April 9, 2006 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! Quote Link to comment Share on other sites More sharing options...
nothix Posted April 9, 2006 Share Posted April 9, 2006 Hmm not sure, would this work?[code] <?phpif($row_rsalumni_database1['display_email'] == "Y"){ echo '<a href="mailto:' . $row_rsalumni_database1['address_email'] . '">';}else{ echo "$row_rsalumni_database1['address_email']";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Ansel_Tk1 Posted April 9, 2006 Author Share Posted April 9, 2006 darn - tried that and didn't work. all i got was a blank screen. some php error i guess. Quote Link to comment 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.