0

I am pretty sure this will be an easy task to do for some PHP programmers I just can't figure it out how to do it. I am displaying some info from my database but want to be able to display it as Hyperlink text instead of the whole website so when someone click on "Website" it will take them to the url. Here is my code:

 <li style="margin-left: 50px;font-family: Myriad Pro Bold ! important;"><b style="margin-right: 20px;">Website:</b> <?php echo $row->website; ?></li></li>

I am looking forward to add 2 texts to the code for example:

 <li style="margin-left: 50px;font-family: Myriad Pro Bold ! important;"><b style="margin-right: 20px;">Website:</b> <?php [SHOW: (**Website** as a hyperlink text) (**Blog** as a Hyper link text) echo $row->website; ?></li></li>

Thank you!!!

2
  • What does $row->website contain? Commented Oct 29, 2013 at 20:47
  • Pulls Website URL from phpmyadmin database Eggyal Commented Oct 29, 2013 at 20:49

2 Answers 2

3
<a href="<?php echo $row->website; ?>"><?php echo $row->blog; ?></a>

Just guessing that $row has a member called blog as well that has the title, and that $row->website is the full url (http://bleh)

Sign up to request clarification or add additional context in comments.

11 Comments

Assuming short tags are "ON"
I don't judge/estimate people's (PHP) skills, however many do not even know what the term means lol. +1 for added explanation ;-)
You shouldn't use the shorthand as it's OFF by default in 5.3 and newer, I believe.
@ahwm: Serves you right for not using smarty or some other template engine. :)
Well let's wrap this one up by accepting the answer as correct @JohnLee - seems like this one's got a "Happy Ending" after all. ;-)
|
0

If the href is already within a string, you have two options:

Single/Double quotes

$string = '<a href="http://google.com">Google</a>';

Escaping

$string = "<a href=\"http://google.com\">Google</a>";

Otherwise, you can insert PHP into your link, like so:

<a href="<?php echo $row->link; ?>">Google</a>

If this is not what you are looking for, I am sorry I misunderstood the question.

Edit:

I suggest you use CSS rather than inline styles, would simplify your code and look less sloppy.

2 Comments

THANK YOU!!!!!! This ius exactly what I was looking for. I also do what I can, I am in the learning process but I agree with you about the CSS. Final Code: <li style="margin-left: 50px;font-family: Myriad Pro Bold ! important;"><b style="margin-right: 20px;">Website:</b> <a href="<?php echo $row->website; ?>">Website</a></li></li>
If this is the result you were looking for, I suggest you mark this post as the correct solution so other people can see easily what worked for them, saving them time on their research. I personally don't try anything on a post that hasn't been marked as solved since I do not know if their was a proper solution to the problem at hand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.