Jump to content

[SOLVED] Checkboxes with catorgories?!


littlevisuals

Recommended Posts

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

 

gKY4o.png

 

However each image that is uploaded needs to be tagged with one or multiple cats, here is the gallery table for the images.

 

V9mvw.png

 

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!!  :shy:

 

 

 

               

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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  :D

 

 

 

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.