MySQL 注释表
我在名为“find.php”的文档中创建了一个页面链接,并使 $id
等于一篇文章的 id。当您点击它时,URL 看起来像 find.php?id=w/e
。我希望能够在页面上发表评论。例如,如果我想在 find.php?id=40
上发表评论,我将如何显示评论?顺便说一句,有一个文章表和一个评论表。
作为参考,我将评论表设置为“
com_id int (11)
title text
user varchar (255)
msg text
我还需要外键吗?”
I made a link to a page in a document named "find.php" and made $id
equal to the id of an article. When you click on it, the url looks like find.php?id=w/e
. I want to be able to post comments on the page. For instance if I wanted to post a comment on find.php?id=40
, how would I display the comments? By the way, there's a table for the articles and a table for the comments.
For reference, I set up my comments table as
com_id int (11)
title text
user varchar (255)
msg text
Would I need a foreign key also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
tableArticle:
tableComment:
显示注释:
您的 SQL 查询:
您的代码(请注意,我现在无法测试语法):
tableArticle:
tableComment:
To display comments:
Your SQL query:
Your code (note that I can't test the syntax now):
是的,您需要从评论表到文章表的外键,以便您可以引用每个评论对应的文章。
Yes, you will need a foreign key from the comments table to the articles table, so you can reference which article each comment is for.