Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900