22, November 2008

displaying profile image thumbnail in the <example.php> page - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: displaying profile image thumbnail in the <example.php> page
« previous next »
Pages: [1] Print

Author Topic: displaying profile image thumbnail in the <example.php> page  (Read 544 times)
Atari ST fan
*
Posts: 8
64 credits
Members referred : 0


« on: Apr 30, 2007, 01:17:24 PM »

I'm a php/mysql newbie, and I have been playing around with access_user_class for about two weeks.
Today I wanted to find a way of displaying a profile thumbnail image when the user has logged in and goes to <example.php>.
To achieve this I created a folder in the filesystem to hold the imagefile, and a new field in the table <users> in the database to hold the URL to the imagefile.
Here's the php-code that was added to <example.php>, and I would like some comments to find out if I did this the correct way or not :

<img src="
            <?php
   
      #connecting to database
            mysql_connect("localhost", "db_username", "db_password");
            mysql_select_db("db_name");
               
      #defines the variable $image

                # table name="users", field name that holds the URL to the imagefile="profile_thumb"

            $image = mysql_query("SELECT profile_thumb FROM users WHERE login='$page_protect->user'")
            
            or die(mysql_error());
   
#displaying the result of the db query
            while($result_image = mysql_fetch_array( $image ))
            {
            echo $result_image['profile_thumb'];
            }
            
#disconnecting from mysql
            mysql_close();
            
            ?>
" border="1">

This is how the script works (. . . or at least how I think it works) :
The script accesses the database, finds the correct table, looks for the field that contains the image-URL's and finds the URL that belongs to the user that is currently logged in.
To find the correct username and the URL that belongs to it,  it uses the variable $page_protect->user
Instead of displaying the URL as text, it diplays the URL inside a <img src>-tag.

I would like some comments on this please. -Is this sensible php-scripting, or am I totally mistaken?
The script actually works, so maybe I'm at least on the right track  Smiley
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Apr 30, 2007, 01:30:20 PM »

you should use one of the profile user fields, this way you can use the existing methods and you have no problems with later class updates


Last blog : Just a better Internet portal provided by Google
Atari ST fan
*
Posts: 8
64 credits
Members referred : 0


« Reply #2 on: Apr 30, 2007, 01:54:32 PM »

I have been thinking the same,-using one of the fields in the profile user table would be better. The problem is, I would need more fields in the profile user table as time goes by. I've tried to use one of the existing fields, and even adding new fields but I can't make that work. Adding new fields to the profile user table is easy, but it seems like new fields need to be defined in some way so that the access_user_class can use them.
Being a newbie, this is something I don't understand.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Apr 30, 2007, 01:56:29 PM »

check this thread:

http://www.webdigity.com/index.php/topic,2345.0.adding+new+fields+to+the+profile+table.html Visit through proxy

keep the user table clean otherwise you start suddenly your own branch Smiley


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6488
Tags : access user class Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: displaying profile image thumbnail in the <example.php> page
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 03:57:22 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.397
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Janai

36 Guests, 4 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.