Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:21:34+00:00 2026-05-23T04:21:34+00:00

This is a very amateur question (don’t rate me down for it) but how

  • 0

This is a very amateur question (don’t rate me down for it) but how would I create a column

for comments

containing the id of the post they are assigned to?

For example if I was to post a comment on post #48, how would I set that up in MySQL so the

comment shows up on post #48 and not all of the posts?

Thanks in advance:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:21:35+00:00Added an answer on May 23, 2026 at 4:21 am

    Its a one to many relationship (one post can have many comments) so you’ll be wanting a new table for it.

    comments_tbl
     - comment_id  |   int(11) auto_increment
     - post_id     |   int(11) (FK to post table)
     - author_id   |   int(11) (FK to the user table OR author_name)
     - date        |   datetime
     - comment     |   text
    

    And if you want to be able to flag and moderate comments you may wish to include something such as:

     - date_approved  |  datetime
     - flagged        |  int(1)
    

    Your SQL then to display comments for a post would be like

    mysql_query("SELECT comment_id, author_name, comment FROM comments_tbl WHERE post_id = '$postid' AND date_approved IS NOT NULL AND flagged = '0'");
    

    To add a comment to the database:

    mysql_query("INSERT INTO comments (post_id, author_id, date, comment) VALUES ('$postid', '$author_id', '$date', '$comment');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This probably is a very very basic question but i can't seem to find
I'm sorry for this very newbish question, I'm not much given into web development.
I find this very strange, must be something I'm doing wrong, but still... I'm
This one is probably very simple, but I can't seem to get it working.
I have this very simple button that I would like to hide <input type=button
Really having an issue debugging this...the reason why is probably very simple but I'm
This very well my be a SuperUser.com question, however it's directly related to my
Linq to SQL has this very simple model: DataContext and attributes [Table] and [Column]
consider this very short T-SQL code that does a test on a nullable column
This very simple code gives me tons of errors: #include <iostream> #include <string> int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.