如何在论坛的问答下方添加评论选项? [英] How can I add comment option under the question and answer in a forum?

查看:112
本文介绍了如何在论坛的问答下方添加评论选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的学校项目创建一个论坛,为此我必须添加问题,然后只有注册用户才能回答问题或发表评论.但是如何在我的网站上添加CodeProject之类的commnet选项.

我不知道如何在数据库中管理它们.评论还显示对问题/答案发表评论的用户名.另外,我该如何检查问题所有者正在检查答案,并向他/她显示Answer of question myself的按钮.如果有人能帮助我解决这个问题,我将非常感激.

I''m trying to make a forum for my school project for that I''ve to add questions and then only registered user can answer them or comment. But how can I add commnet option like CodeProject on my website.

I don''t know how to manage them in database. The comments also show the username who comment on question/answer. Also how can I check that the question owner is checking the answer and show him/her the button of Answer of question myself. I will highly thankful if someone help me out from this trouble.

推荐答案

我假设您知道如何设置数据库以及如何在数据库中读写数据.
这不是一件容易的事.首先,您需要考虑如何设置数据库.您是否有一个名为Question的表,该表与名为Comment的表有详细的关系?您的问题和评论表都将需要与用户的关系.两者都需要知道创建它的用户.
现在,在您的页面中,您将需要获取问题(页面上可能会显示部分问题,并且当用户单击它时您会知道其ID)和每个详细信息注释.如果您使用的是诸如实体框架之类的ORM,这将几乎自动为您完成.您只需要显示它们即可.
现在,对于您的问题,您将必须检查当前正在查看页面的用户是否是该问题的所有者(您确实将UserID存储在问题表中,对吗?).如果当前查看者是所有者,则会看到我自己回答问题"按钮.您必须在代码中进行设置.您还可以使用户能够编辑自己的问题或评论.

我不会向您展示代码,因为一个人可以写一篇完整的文章.
实际上,人们已经撰写了有关它的文章.
JumpyForum:受Code Project论坛/讨论区/留言板的启发 [
I assume you know how to set up a database and read/write data from and to it.
This is no easy task. First of all you need to think about how to set up your database. Will you have a table called Question with a detail relation to a table called Comment? Both your Question and your Comment table will need a relation with User. Both need to be aware of the User that created it.
Now in your page you would need to fetch the Question (you probably have a portion of the questions shown on a page and when a user clicks it you know its ID) and every detail Comment. If you are using an ORM such as Entity Framework this will be done for you almost automatically. You just have to show them.
Now for your question you will have to check if the user that is currently viewing the page is the owner of that Question (you did store the UserID in your Question table, right?). If the current viewer is the owner it sees the "Answer question myself" button. You''d have to set this in your code. You could also give the user the ability to edit his own question or comments.

I am not going to show you code since one could write an entire article about this.
And in fact, people have written articles about it.
JumpyForum: Inspired by Code Project Forum / Discussion / Message board[^]
I hope I''ve given you enough idea''s about how to finish your assignment. The implementation is up to you.
For further questions I suggest you speak to your teacher.


这篇关于如何在论坛的问答下方添加评论选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆