Jump to content

[SOLVED] Showing images from Database


stelthius

Recommended Posts

Hello again guys,

 

Ive written this

 

<?php
include('include/session.php');

$res = mysql_query("SELECT * FROM `users` ORDER BY `signupdate` LIMIT 5"); 

while ($row = mysql_fetch_assoc($res)) {
echo "New User : " . $row['username'] . "";
echo "<img src=include\avatar\"". $row['avatar']."\><br>";

}
?>

 

To display the 5 newest members on the site, i also want it to show there avatar i have it working in a sense i just have a small issue of actually getting it to show the image instead of giving this

 

/test/include/avatar/noavatar.png

 

Which will display the users Avatar its giving me the following,

 

/test/include/avatar%22noavatar.png/

 

It's wrong but im not sure why its actually doing it anyone have any suggestions ? i have browsed google for some tips & hints but i have come to no avail.

 

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/141604-solved-showing-images-from-database/
Share on other sites

Ok i have figured out the trailing slash problem the only one i am well and truely stuck on is how to stop it adding %22 when it should just be adding a /

 

its now showing

 

/test/include/avatar%22noavatar.png

 

Intead of

 

/test/include/avatar/noavatar.png

 

Any ideas or tips are greatly appretiated, thanks rick

<?php
include('include/session.php');

//add some efficiency
$res = mysql_query("SELECT `username`,`avatar` FROM `users` ORDER BY `signupdate` LIMIT 5"); 

while ($row = mysql_fetch_assoc($res)) 
{
echo 'New User : '.$row['username'];
echo '<img src="include/avatar/'.$row['avatar'].'"><br>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.