Link Issue

  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13

Post 3+ Months Ago

Hi All

I know this is going to end up stupidly simplistic and i'll kick myself for not figuring it out but I'm running out of patience now!

I have a link that looks like the following in php:

Code: [ Select ]
$username = '<a href="../'.$cur_post['username'].'" target="_parent">'.pun_htmlspecialchars($cur_post['username']).'</a>';


This shows me the username and has a link to the profile. Brilliant that all works.

Now I have a piece of code which displays an avartar:

Code: [ Select ]
$user_avatar = '<img src="http://www.domain.com/community/viewthumb.php?user='.$cur_post['username'].'" />';


That all works too.

What i'm trying to do is edit the code that shows the avatar so it links through to the user profile (which is the first bit of code). I've got both pieces of the jigsaw here, all my efforts to piece them together are resulting in errors though.

Any help would be much appreciated :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

Place an anchor tag around your image tag...

Code: [ Select ]
$user_avatar = '<a href="../'.$cur_post['username'].'" target="_parent"><img src="http://www.domain.com/community/viewthumb.php?user='.$cur_post['username'].'" /></a>';
  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13

Post 3+ Months Ago

Hi UPSGuy,

Thanks for the suggestion, unfortunately this just stops the avatar from showing completely :(

I think because its missing this bit: '.pun_htmlspecialchars($cur_post['username']).'

But i tried putting that back in too and it gives me yet more unexpected T string errors or something :(
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

The syntax should be correct...something's off about the variables getting passed in that I can't see from what you've shared.

Can you post the rendered html for me?

Foundationally, the structure is correct to show the image and make it a link. Try defining a height and width on the image and see if that helps unless you can share more code?

Code: [ Select ]
<a href="http://www.google.com">
    <img src="something.gif" />
</a>
  1. <a href="http://www.google.com">
  2.     <img src="something.gif" />
  3. </a>
  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13

Post 3+ Months Ago

OK I've been quite silly here, I forgot to change domain.com back to the URL in your code, so of course it didn't show. Sometimes I think I should have been born blonde!

Thankyou for your help UPSGuy, your code works absolutely perfectly :)

Your a star! xxx
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

No problem, you know where we are if you need more help. ;)

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 193 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.