Jump to content

Recommended Posts

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.

 

:)

Link to comment
https://forums.phpfreaks.com/topic/72810-link-from-variable-in-php/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.