Jump to content

How to display comments under each post


Stefany93

Recommended Posts

Hello colleagues,

 

Please help me! Here is the issue:

 

I have two tables in the Mysql DB one called posts and its columns are

 

id title contents category_id datetime

 

And I have another table whose name is comments and its fields are:

 

id name comment

 

So far I managed to display the comments from the databse, but the problem is that I want to display comments only that correspond to a specific post from the DB. Please, please help me, I have been trying to figure it out for weeks and still can't find the answer!

 

Thank you!

 

Best Regards

Stefany

Link to comment
Share on other sites

The table you had was probably fine for the comment table with for example id as the AUTO-INCREMENT field.  You'll want to have that id field to identify the comment for updates etc.  You just need to add the post_id field as noted and add this id when comment is added.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.