bolty2uk Posted October 11, 2007 Share Posted October 11, 2007 hello.. i have a quick query and i would appreciate it very much if someone could give me some advice or point me to a tutorial/guide that details this.. I have a mysql database and in that i have a users website and contact details.. when i display them on the page i use this code to make there details linkable.. <a href="<?php echo $website; ?>" target="_blank">website</a> | <a href="mailto:<?php echo $email; ?>?subject=Enquiry sent via my website" >contact</a> Now the problem i have is if a user hasnt put in a email or website or both then these links will still be there but wont work.. So what i am after is a way of displaying n/a if i dont have these details.. after doing a bit of reading up i tried this.. <a href="<?php echo $website; ?>" class="style3" target="_blank"><?php echo 'website';if (empty($website)) echo 'N/A'; ?></a> but this will show 'websiteN/A'.. so i am after a few ideas on how best to achieve this, so basically if the database hasnt got any info for the user it will display n/a.. many thanks for any responces. Quote Link to comment https://forums.phpfreaks.com/topic/72810-link-from-variable-in-php/ Share on other sites More sharing options...
GamingWarrior Posted October 11, 2007 Share Posted October 11, 2007 if new to php my self but <a href="<?php echo $website; ?>" class="style3" target="_blank"><?php if (empty($website)) { echo 'N/A'; }else{ echo 'website';} ?></a> that might work, might be worth a shot. Quote Link to comment https://forums.phpfreaks.com/topic/72810-link-from-variable-in-php/#findComment-367197 Share on other sites More sharing options...
piznac Posted October 11, 2007 Share Posted October 11, 2007 Not sure if this is what you want but try this: <?php if(empty($website)){ echo "N/A"; }else{ echo "<a href=\"$website\"class=\"style3\" target=\"_blank\">Link</a> ";}?> Sorry had to modify,.. Im a bit slow this afternoon LOL Quote Link to comment https://forums.phpfreaks.com/topic/72810-link-from-variable-in-php/#findComment-367200 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.