Handsken
Handsken

Reputation: 674

How can i pair images in my DB?

I had a hard time giving this question a title, i hope im clear enough. Im using PHP & HTML with a MYSQL Database.

See I have a member site, where every new member gets a randomly chosen football player as their avatar. The football player avatar is assigned from a folder named 'avatars'. Once the user is registered, the avatar is moved to a folder named 'used_avatars'. Every image is named as the football player, because i want to display the name of the chosen player on the users member page.

Here's the real question: I want to add a flag representing the players nationality on the member site. But I have several Brazilian players and only one Brazilian flag. How do i pair my 5 players with the one flag. I was thinking of naming the images "brazil-ronaldo", "brazil-carlos" and then in some way in PHP separating the country from the name and match them with a flag and a avatar. Does this make sense? Is there any better way of doing this? I guess I need to create a new table in my database that keeps record of flag and avatar match?

Upvotes: 0

Views: 91

Answers (2)

जलजनक
जलजनक

Reputation: 3071

Instead of assigning a random player avatar for new members, assign a default avatar(cartoon).

  1. Members/Users table will have a column avatar_id.
  2. A table avatars_history (member_id, avatar_id, order). where order wil be the sequence in which they were changed. You can have date too if necessary.
  3. A table football_players (player_id, country_id, full_name, dob, world_rank, etc).
  4. A table avatars (player_id, avatar_id) where avatar_id is the filename of the picture. Meaning a single player can have multiple pictures.

And keep all avatars(player pictures with unique names) in a single folder.

Upvotes: 1

snitch182
snitch182

Reputation: 723

Hope this helps:

You need a table for players containing field for a nationality id and a table with nationalities with the names for the flags.

This way you can select the player and join the nationality via the id.

All you have to do then is save the player id in the user "profile".

Upvotes: 2

Related Questions