Jump to content

Another question


justAnoob

Recommended Posts

What would the best way to link some tables for something like this.......  I have a lot of users, with their passwords and email.  Also have their address information.  And then also have some picture information, such as image path, image name and image description.(pictures of the family). How would I set up the table for the picture information to hold muliple image info???  Each time a user uploads a new pic, could PHP just add a new field in the mysql table... such as this    imgpath1 imgname1 imginfo1,,,,imgpath2 imgname2 imginfo2,,,, and so on. Any of you understand what I am trying to do? I would like to keep all of my tables linked together with an id so I could pull certain info on an admin page. Any ideas?

 

Link to comment
Share on other sites

Each table should use a unique key that is created when a user is added. Then tie the images to that user like this.

Image table

Unique_Key | Image_Name | Image_Path | Image_Details | imag_etc

Table for Users ex:

Unique_Key | User_Name | User_Login | User_Pass | User_address | User_etc

Unique_Key is an shared key, again created by the user table.

Link to comment
Share on other sites

Ok, cool. Lets say a user is already registered and that user has one image uploaded. When they go to upload another image, can i have it setup so a new field is automatically inserted into the table?, or should I just setup the table to accept, lets say, 3 images with info. and then let the user know that they can only have 3 images uploaded to the site? I would really like them to be able to have as many pictures as they would like, but I'm not sure how to set it up that way.

Link to comment
Share on other sites

Don't add more fields. Ok so you understand tables right. Fields are equal to columns. Instead of adding more fields or columns when you insert a picture you just add another row.

The image is tied to the user because it will always use the users Unique_Key. Thus when you extract a users images do a search for all images that have the same Unique_Key as the user. Do you get it now?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.