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
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

Link to comment
Share on other sites

<?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>';
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.