Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends

I am developing one site where users can post thier comments. I wanted to know how to save these comments in database.

I was thinking to add one column dynamically into database table for each user entering comment using ALTER command and then to display the user comments, get the row from the database table and then display each column sequentially.

Is this a proper approach to achieve what I wanted to do?

Any guidence will be a great help to me.
Posted

Why bother doing all that? Why not just have a Comments table with these columns: userId, blogPostId, date-time?
 
Share this answer
 
Hi Nishant
Thanks for your reply but it didnt answer my question, how to save all the comments entered for any specific blog post.
The blog post contents are saved in the database table "blogs" with blogPostId as the primary key. But I am struggling to know how and where to save the comments entered by user for this specific blog post.

Any help on this will be appreciated.
 
Share this answer
 
Comments
tbprakash 4-Aug-17 9:02am    
hi makwce,

I know it's so late but this may help visitors in the future. What Nishant meant when he said "create another table" is that you can maintain a separate table for comments with a column 'blogpost' which links to 'blogPostId' in your blogs table using foreign key.

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