Displaying mySQL images determined by category and/or tag
I'm relatively new to PHP/mySQL and I'm trying to develop a portfolio of my images. I have already set up an admin control panel where I can upload a photo from my hard-drive and store data about the image (including it's path) into a database. What I'm wondering is, could anyone point me to a tutorial or information on how to set up a category and/or tagging mechanism, so I can assign multiple tags/categories for an image, and have them be displayed based on that.
For example, I have an image: npr_001_day.jpg. This is a 'mountain' picture and also a 'winter' picture. I want to enable it so when I click on a link for 'mountains' it wil开发者_开发知识库l display. I also want it to display when i click on the 'winter' category too.
I've been looking on the web for a while and have been able to find anything usable.
Thanks ahead for any help! Tre
This is what's called a "many to many" relationship in relational database lingo. I'm assuming you have an IMAGE table where you image data goes. You'll need to add a CATEGORY table to store your categories and a CATEGORY_IMAGE table to store relationships between images and categories.
CATEGORY_IMAGE would have two columns, one for the ID of an image, and one for the ID of an associated category. Here's a pretty good overview of what you need - http://www.tomjewett.com/dbdesign/dbdesign.php?page=manymany.php
精彩评论