Page 1 of 1

Creating an Avatar System

Posted: Sun Apr 26, 2009 7:50 pm
by Teonnyn
I am trying to figure out the best way to build an avatar system for my users. I figure it's most likely as simple as an If (!'$user'avatar) then display no-avatar.jpg else get database query, display currently selected avatar. However, it's a bit confusing. Could anyone tell me if I'm on the right track or point me in the right direction if I am not?

Re: Creating an Avatar System

Posted: Mon Apr 27, 2009 11:21 am
by papa
You probably have a user table in your database, create a avatar field with the name for that image.

Then when fething the user info you could simply use, for example:

Code: Select all

 
 
//mysql fetch etc
 
$avatar = !empty($row['avatar']) ? "<img src=\"path/to/avatar/{$row['avatar']}.gif\" />" : "";
 
echo $avatar;