littlevisuals Posted July 14, 2009 Share Posted July 14, 2009 Hi everyone Im having a real headache getting my head round a solution for my database :-\ I have followed the checkbox tutorial which instead of admin privilages ive changed it to Catorgories. here is the the catorgories table, the admin can add new ones for a drop down on the main page However each image that is uploaded needs to be tagged with one or multiple cats, here is the gallery table for the images. Im racking my brains trying to figure what field(s) i need in the gallery table to add in order to associate the image with multiple catorgories, not only that but new catorgories will be added so I cant just add static fields!? If anyone has a solution I would be very grateful indeed!! Quote Link to comment https://forums.phpfreaks.com/topic/165994-solved-checkboxes-with-catorgories/ Share on other sites More sharing options...
xtopolis Posted July 15, 2009 Share Posted July 15, 2009 The table from your second image needs to be broken up into smaller tables with relational data. (you can read this article: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html) For your specific problem, you would add another table, and not have the "cat" column in your ... whatever that long image is. The new table would have the relationship of (one) image -< to -< (many) categories So the lookup table you would make would at basic form be this: [pre]image_id | category_id ---------------------------- 107 | 2 107 | 4 108 | 2 109 | 1[/pre] If that isn't clear enough, read the article I posted, and then if you still have questions, post back here. I strongly suggest reading the article first, then modifying your image table which has too many columns on it that are not related. Quote Link to comment https://forums.phpfreaks.com/topic/165994-solved-checkboxes-with-catorgories/#findComment-875531 Share on other sites More sharing options...
littlevisuals Posted July 15, 2009 Author Share Posted July 15, 2009 Thankyou, I understand the concept but having trouble with getting the image id and cat id to insert into the lookup table. All my data for these two fields are 0's everytime I click add? I'll post this in php as you have solved my initial problem Quote Link to comment https://forums.phpfreaks.com/topic/165994-solved-checkboxes-with-catorgories/#findComment-875771 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.