Results 1 to 6 of 6

Thread: MySQL

  1. #1

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Talking 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:::...
    6 Years

  2. #2
    Addicted Member techwizz's Avatar
    Join Date
    Apr 2005
    Location
    U.S.A.
    Posts
    246

    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.

  3. #3

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    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.
    Last edited by ...:::ONE:::...; May 26th, 2005 at 10:55 PM.
    6 Years

  4. #4

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    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.
    Last edited by ...:::ONE:::...; May 26th, 2005 at 11:07 PM.
    6 Years

  5. #5
    Addicted Member techwizz's Avatar
    Join Date
    Apr 2005
    Location
    U.S.A.
    Posts
    246

    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







    Last edited by techwizz; May 28th, 2005 at 12:40 AM.

  6. #6

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Re: MySQL

    Thanks, thats all I needed to know. I just need to modify a few things and it should work perfectly.

    ...:::ONE:::...
    6 Years

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width