avatar with user information

0

It is the following personal, maybe this is very basic, but how do I associate the image of a folder with images for example to the user of id 1 in the bank? Will user 1 have the image 01 of the img folder? Would you recommend creating the "folder path" with the name of the image in the database and creating a relationship with the users table? Or do you have other more useful techniques currently used for this?

    
asked by anonymous 17.07.2015 / 19:22

1 answer

2

Create a column in the user table to store the avatar path according to its structure:

ID NOME  AVATAR
1  Asura img/avatares/123456.jog

Now whenever you have the user record you will have the path of the image to load:

<img src="<?php echo $usuario->avatar;?> />

I find this interesting way because you can separate the images by context, let's assume you have the produtos table, you can create the img/produtos directory and at the time of saving the product, you put the image path in the or even in another table if the product has more than one image.

    
17.07.2015 / 19:53