I am developing a CMS for a company and they want a flyout page that displays multiple images for their product.
The problem I am facing is that I am trying to figure out the best way to setup the database so that the customer can:
// add as many pictures to a product that they want
// delete the images individually from an update page
Should I set up another database table to hold all the images and associate it with the products?
What should be my headings for the image table?
I guess I could set a defined limit on the amount of pictures but I do not really want to do that.
Thank you for your time.
Mike
Multiple images per Product
Moderator: General Moderators
Re: Multiple images per Product
If you have a second table, you could link the pictures by say the product code or id, and have this as a foreign key in the other table but not a unique key. That way you can call all pictures with a matching id later on and use as many as you like?
Re: Multiple images per Product
Thank you for your response.
// How would I setup the structure of that table?
I know how to associate the database tables but I am trying to figure out how to get those images to populate the table without setting headings for each picture.
I guess I would have to setup a query that creates a new column when a new picture is added?
Thanks
Mike
// How would I setup the structure of that table?
I know how to associate the database tables but I am trying to figure out how to get those images to populate the table without setting headings for each picture.
I guess I would have to setup a query that creates a new column when a new picture is added?
Thanks
Mike
Re: Multiple images per Product
Personally, I would make it as simple as possible, I really dont see you needing much more than a unique id for the image, the id of the product to link to and then a filepath for the image. At least, thats how I would do it if I had to. Others may say otherwise.
Re: Multiple images per Product
I would just do it with the file and directory naming structure.
Have a folder for each product and always use the same naming convention, e.g. productX57, productS-52, etc.
Then for each image, automatically append a number to it, like productX57_1.jpg, productX57_2.jpg, etc. and keep it in the corresponding product folder.
Then all you have to do is look for the directory with the same name as the product, and look inside it to see how many images there are and what they are.
Use the database to keep track of the headings (I'm assuming this means captions or descriptions?) for each product.
Have a folder for each product and always use the same naming convention, e.g. productX57, productS-52, etc.
Then for each image, automatically append a number to it, like productX57_1.jpg, productX57_2.jpg, etc. and keep it in the corresponding product folder.
Then all you have to do is look for the directory with the same name as the product, and look inside it to see how many images there are and what they are.
Use the database to keep track of the headings (I'm assuming this means captions or descriptions?) for each product.
Re: Multiple images per Product
I think you are on the right track but the person who will be doing the uploading will not want to rename the files. I am doing some experimenting with this and I think it would be best just to leave the database out of it and split it into folders like you suggested.
I might make the folders correspond to the product name I have stored in the DB.
Thanks for you help and suggestions!
Mike
I might make the folders correspond to the product name I have stored in the DB.
Thanks for you help and suggestions!
Mike