machoe Posted December 12, 2009 Share Posted December 12, 2009 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 Link to comment https://forums.phpfreaks.com/topic/184882-how-do-you-make-comments-for-blogs-via-php-and-mysql/ Share on other sites More sharing options...
conker87 Posted December 12, 2009 Share Posted December 12, 2009 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}" Link to comment https://forums.phpfreaks.com/topic/184882-how-do-you-make-comments-for-blogs-via-php-and-mysql/#findComment-975995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.