views:

57

answers:

3

Hello,

I've saved a user's respective picture in a folder named 'profileportraits'. So when a user uploads their picture, it is saved into that folder. Furthermore, I also save the 'portrait path', i.e. the location/name of the photo onto a MySQL database for user data. My question is: I am able to echo the Portrait Path, where the user's portrait is stored onto the page. But how will I display the actual photo onto the page? I.e. how can I turn the file path into the actual picture? Will I have to match the path that I retrieved from MySQL to the directory? or something else? Below is a bit of code.

{
echo $row['PortraitPath'];
}

With the code above, I am able to echo the actual path, which is: profileportraits/DSC00310.JPG. I simply want to turn this path of the picture, into the actual picture. Thank you.

+6  A: 
<img src="<?php echo $row['PortraitPath']; ?>" />

or

<?php
echo "<img src=\"{$row['PortraitPath']}\" />";
?>
Brendan Long
Don't forget the ALT attribute. ;) Just a thought was that _PortraitPath_ was perhaps the server-side path which didn't quite match the appropriate client side URL? If not then great, otherwise you'll need to convert it to a URL.
w3d
+4  A: 

Why not use the path as the source of an image tag:

echo "<img src=\"{$row['PortraitPath']}\" />"
Andreas
A: 

from the 2 code that Brendan mentioned, I prefer the 1st one

<img src="<?php echo $row['PortraitPath']; ?>" />

as that will get colorized/highlighted better in notepad++

fedmich