Link Issue

  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 02, 2009
  • Posts: 13
  • Status: Offline

Post June 2nd, 2009, 1:06 pm

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 2nd, 2009, 1:06 pm

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post June 2nd, 2009, 1:09 pm

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>';
I'd love to change the world, but they won't give me the source code.
  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 02, 2009
  • Posts: 13
  • Status: Offline

Post June 2nd, 2009, 1:18 pm

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
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post June 2nd, 2009, 1:27 pm

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>
I'd love to change the world, but they won't give me the source code.
  • HollyHunter
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 02, 2009
  • Posts: 13
  • Status: Offline

Post June 2nd, 2009, 1:37 pm

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
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post June 2nd, 2009, 1:46 pm

No problem, you know where we are if you need more help. ;)
I'd love to change the world, but they won't give me the source code.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 149 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
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.