Creating an Avatar System
Moderator: General Moderators
Creating an Avatar System
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
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:
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;