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
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

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.