-
MySQL
I use mysql as a database for my website to store all the user information. I wanted to know if it was possible to save a location like (c:\documents and settings\my documents\server\root\images\image1.jpg) to the database and use it to load an avatar for the user its located it. in other words the location will be stored along with the information of the user, then when the user logs in the picture will show.
How could I get the picture to load when the user logs in?
Thanks
...:::ONE:::...
-
Re: MySQL
You would generally know what folder the image was going into and then just insert that location (ex. www.mywebsite.com/images/$imagename)
This code below wil show defined image (avatar or other)
PHP Code:
<?php
//Declare image
$image1 ="http://lists.w3.org/Archives/Public/www-xml-infoset-comments/2001JulSep/att-0104/computer.jpg";
//Display image
echo "<img src='$image1'>";
?>
It should be something simaler on you local server.
-
Re: MySQL
Wait a minute, I am not at home right now so I wanted to know if this code was getting its information from the database.
-
Re: MySQL
I didn't want to get an image from another website or from my root server folders, I wanted to get the location from the MySQL database and use that location or source to load a picture from my server.
There is different images for each user, and each user has its own part of the data base with their information, the image is on my server, the location of the image (C:\user.jpg, or http://www.mysite.com/myavatar.jpg, etc.) is stored with the user information, when the user logs in the image location will be source of the image that loads.
-
Re: MySQL
I know. I was just showing / suggesting a way to do it.
Make it so the location of the picture is saved. designate one directory for the images. Then only the name of the picture is named.
If a user table called users
with
-----------
userid
avatar
-----------
then on the page that it is to be displayed to display the image you could use code something like this. Im certian the code is not correct. But you can get the jest of it.
PHP Code:
//Define the image folder
$imgfolder = "http://mywebsite/images/avatars/";
//ask the database to look for the data
$query = "select * from users where ".$userid." like '%".$userid."%'";
$result = mysql_query($query);
{
$row = mysql_fetch_array($result);
//Show the username
echo "<p>Username: ";
echo ($row["userid"]);
//Show image and location
echo "<p>Avatar: ";
echo '$imgfolder($row["avatar"])';
}
Again sorry for the poor use of the language, but i dont have time to test it all or find the correct code in a book somewhere.
Hope that helped more than it hurt. lol
:D
-
Re: MySQL
Thanks, thats all I needed to know. I just need to modify a few things and it should work perfectly.
...:::ONE:::...