Jump to content

advice on creating a comment addon


Dexlin

Recommended Posts

Hi all,

 

I have created a site that i would like to add comments to the post. This is how i have done it so far.

 

it calls on example.php?id=$id

 

which gets the $id and puts it into the the query "SELECT * FROM table WHERE id=$id

 

the fills the page with a title and body text

 

This all works great but i was just wondering what would be the best way of creating the comments addon so when each requested post i.e example.php?id=$id is called it will display the title and body text as well as  the comments for that post.

 

 

Any help will be great.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/266125-advice-on-creating-a-comment-addon/
Share on other sites

Create a new table called comments.

 

id, parent_id, body, posted_by, date, whatever else.

 

id - Auto-increment primary ID

parent_id - the 'id' column of the article the comment is attached to

 

You can then get all of an articles comments using

 

SELECT * FROM comments WHERE parent_id = $id ORDER BY date DESC

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.