Anoxy
Anoxy

Reputation: 953

Adding an HTML link with PHP

i have this problem i hope some of you can help me with. I try to make a html link that get the link from my database.

echo "<p><pre><a href=$Feed['socialfacebook']><img src=facebook-24.png></a></pre></p>  

Upvotes: 0

Views: 74

Answers (5)

vpzomtrrfrt
vpzomtrrfrt

Reputation: 480

Double-quoted strings don't work with array elements quite like that. You should close and concatenate the strings.

echo "<p><pre><a href=".$Feed['socialfacebook']."><img src=facebook-24.png></a></pre></p>"

You might also want to put some quotes on your attributes.

Upvotes: 1

Yassine
Yassine

Reputation: 35

u need to put the variable $Feed['socialfacebook'] in " . $Feed['socialfacebook'] ."

echo "<p><pre><a href=" . $Feed['socialfacebook'] . "<img src=facebook-24.png></a></pre></p>";

and don't forget the ;

Upvotes: 0

azhpo
azhpo

Reputation: 43

Shouldn't it be:

echo "<p><pre><a href='$Feed["socialfacebook"]'><img src=facebook-24.png></a>";

Don't forget that is href="".

Upvotes: -1

George
George

Reputation: 36784

  • Close your string with a double quote and end your statement with a semi-colon,
  • When getting array elements inside a string literal like you're doing, leave out the key quotes,
  • Use single quotes around your attribute in case of any spaces:
echo "<p><pre><a href='$Feed[socialfacebook]'><img src=facebook-24.png></a>";

Eval.in

Upvotes: 1

baao
baao

Reputation: 73221

You need to put the link in '".$variable ."' and the image src should be in ' ', too.

echo "<p><pre><a href='".$Feed['socialfacebook']."'><img src='facebook-24.png'></a></pre></p>";

Upvotes: 2

Related Questions