justAnoob Posted March 5, 2009 Share Posted March 5, 2009 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? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 5, 2009 Share Posted March 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted March 5, 2009 Author Share Posted March 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 5, 2009 Share Posted March 5, 2009 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.