supermerc Posted March 11, 2007 Share Posted March 11, 2007 Hey I have in mind an idea for my site, I want my users to be able to upload images where path will be saved to database with a description so I can have a gallery, then members can rate the images. I would like to know what fields im going to need on my table? Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted March 11, 2007 Share Posted March 11, 2007 id int NOT NULL AUTO_INCREMENT PRIMARY KEY user_id int NOT NULL image_name varchar(50) NOT NULL caption varchar(100) Ok. You'll have the normal 'id' field. The 'user_id' field is the id of the user to which the image belongs. Then the 'image_name' field. It depends on how you set up your directory. Some people throw them all in one directory and some others set up each member with their own folder under the 'images' directory to keep them kind of organized. However you set it up, when you are linking to the image in HTML, you'll be able to insert the path there and just pull the image name from the table. And if you want to give the user their own folder, you'll be able to throw their username in the path there as well. Then there is the optional 'caption' field for holding a little description of the pic. You'll need a separate table for the ratings. id int NOT NULL AUTO_INCREMENT PRIMARY KEY image_id int NOT NULL rating int NOT NULL The id field will keep track of the ratings. The image_id field is the id of the image that has been rated. And the rating of course will be the rating, however you set them up. There might be better ways to do it, but this is what I came up with in a few minutes. Jeremy 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.