显示由类别和/或标签确定的 mySQL 图像
我对 PHP/mySQL 比较陌生,我正在尝试开发我的图像组合。我已经设置了一个管理控制面板,可以在其中从硬盘上传照片并将有关图像的数据(包括其路径)存储到数据库中。我想知道的是,任何人都可以向我指出有关如何设置类别和/或标记机制的教程或信息,以便我可以为图像分配多个标签/类别,并让它们基于此进行显示。
例如,我有一个图像:npr_001_day.jpg。这是一张“山”图,也是一张“冬”图。我想启用它,以便当我单击“山脉”链接时它将显示。我也希望在单击“冬季”类别时显示它。
我在网上搜索了一段时间,并找到了任何有用的东西。
提前感谢您的帮助! 特雷
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 will 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是关系数据库术语中所谓的“多对多”关系。我假设您有一个图像数据所在的 IMAGE 表。您需要添加一个 CATEGORY 表来存储类别,并添加一个 CATEGORY_IMAGE 表来存储图像和类别之间的关系。
CATEGORY_IMAGE 将有两列,一列用于图像的 ID,一列用于关联类别的 ID。这是您需要的一个很好的概述 - http://www.tomjewett .com/dbdesign/dbdesign.php?page=manymany.php
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