Jump to content

link from variable in php ??


bolty2uk

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

Archived

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

×
×
  • 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.