GrahamMercer Posted November 5, 2006 Share Posted November 5, 2006 Hi and first of all thanks to everyone here that takes the time to help out newbies such as myself. I have a conditional IF statement that allows me to add a link to a piece of text if that record has a website, but I would like to also be able to display the text without the link if there is no website associated with the record.The code that I am currently using is <?php if($row_RSsales['website']!='') { ?><a href="<?php echo $row_RSsales['website']; ?>" target="_blank"><?php echo $row_RSsales['name']; ?></a><?php } ?> The trouble with this is that if a particular record does not have a website then the code does not echo the business name. I would like to include an ELSE statement with the IF statement so that when a record does not have a website entry the business name is still echoed, but not hyperlinked.I have been fiddling with code but cannot figure out how to do it. <?php if($row_RSsales['website']!='') { ?><a href="<?php echo $row_RSsales['website']; ?>" target="_blank"><?php echo $row_RSsales['name']; ?></a>;else <?php echo $row_RSsales['name']; ?><?php } ?> doesn't work and I am not sure how to solve it.Any suggestions would be greatly appreciated!thanks,Graham Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted November 5, 2006 Share Posted November 5, 2006 <?php if ($row_RSsales['website'] == '') { echo '<a href="' . $row_RSsales['website'] . '" target="_blank">' . $row_RSsales['name'] . '</a>'; } else { echo $row_RSsales['name']; }?> that should do it.love,jason Link to comment Share on other sites More sharing options...
Lulzim Posted November 5, 2006 Share Posted November 5, 2006 <?php if ($row_RSsales['website'] == '') { echo '<a href="' . $row_RSsales['website'] . '" target="_blank">' . $row_RSsales['name'] . '</a>'; } else { echo $row_RSsales['name']; }?> that should do it.love,jason you changed the condition here from != to == : if ($row_RSsales['website'] == '') it should be like this: if ($row_RSsales['website'] != '') Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted November 5, 2006 Share Posted November 5, 2006 crap. i changed that on my test file and forgot to change it in the post......sorry!love,jason Link to comment Share on other sites More sharing options...
GrahamMercer Posted November 5, 2006 Author Share Posted November 5, 2006 You guys are awesome!Thanks so much for the code (and correction), your help is greatly appreciated.Talk about helpful, less than an hour from when I posted my question and the problem is solved!Cheers,Graham Link to comment Share on other sites More sharing options...
jlhaslip Posted November 5, 2006 Share Posted November 5, 2006 Well, you get lucky sometimes... tee hee hee... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now