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
https://forums.phpfreaks.com/topic/264863-how-to-display-comments-under-each-post/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.