I'm coding a social network and am pulling user's images URL from database to display their profile pic. That works fine. Now I want user images to appear within and on top.... /images/largephoto.png. I have tried using class calling the proper css property as well placed the right code in , as seen below. Unfortunately, whatever I do .... /images/largephoto.png does not appear. I'm developing and testing using Firefox.

<a href='usrprfle.php?prflnm=$value[From_usrnme]'><img style='background: url('../images/largephoto.png') no-repeat; border: none;' height='90' width='90' src='$value[thumbimage]'  alt='$value[From_usrnme]'/></a>

Can this be done and if so how? thanks!

2 answers

orta 244

As that's an inline style, the url will be basesd from the page its on, so your url might be background: url('images/largephoto.png')

Any reason to use that technique instead of a plain img?

Answered about 7 years ago by orta

You're mixing and matching code there. Try putting the background image on the <a> element and making it display: block - it will only be as big as the thumbnail unless you increase the size of it in css.

here's some inline styling so you can see what I mean:

<a href="usrprfle.php?prflnm=<?PHP $value[From_usrnme] ?>" style="background: url('/images/largephoto.png') no-repeat top left; border: none; width: 200px; height:200px; display:block; ">
    <img src="<?php echo $value[thumbimage] ?>"  height='90' width='90'  alt="<?PHP echo  $value[From_usrnme] ?>" />

I've guessed at your path to images and I've put the html attributes inside double quotes and wrapped the php in php tags as that's what I think you're trying to do.

without all the code it's hard to be sure.

Answered about 7 years ago by Tony Crockford