Jump to content

How do you make comments for blogs via PHP and MySQL?


machoe

Recommended Posts

Hi,

 

I am currently doing a project and I want to make a blog. The only thing that I got left which I cannot figure out is how to let users post comments for blogs and keep displaying comments for that blog.

 

In simple words, if I have a blog named 'Hello' and it has text such as 'Hello World', I would like users to make comments on that blog. Obviously I already have 2 tables in MySql which are users and blogs. I need to make another table for comments and link it with blogs.

 

Does anyone know a simple tutorial for this please? Thanks

Make another table called `comments`. with `id`, `blog_id`,`user_id` and `comment` Use whatever login script you have to show the comment box (if you need to login to comment).

 

When inserting the comment into your database:

- Insert the id of the blog from the `blog` table into `blog_id`.`comments`.

- Insert the id of the user from the `user` table into `user_id`.comments`.

 

When selecting comments, use:

"SELECT * FROM `comments` WHERE `blog_id` = {$howEverYouChooseToCollectTheID}"

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.