|All requests||>||What is the best PHP blog comment sys...||>||Request new recommendation||>||Featured requests||>||No recommendations|
by Talha Bin Faisal - 1 year ago (2015-12-13)
I created a blog with PHP and MySQL database. I have created a table where I store all blog details.
Now I want to add a comment system on my blog, so that visitors can post comment about the articles.
I think need an another database table to do that. Then both tables 'title' column would be same, so that I can fetch data both table with the "title". Is there any better idea to do this project?
1. by Dave Smith - 1 year ago (2015-12-13) Reply
your blog table should have a unique id, preferably an integer, for each blog post. Then you include the blog id in the comment table row to relate them. This is a one to many relation, one blog id is used in many comment rows to form the relation.
2. by Talha Bin Faisal - 1 year ago (2015-12-16) in reply to comment 1 by Dave Smith Comment
If I wanna insert same unique id in both table, then I should insert the same id for each blog post & that not with auto increament function. So, when how insert same id in both table???
3. by Dave Smith - 1 year ago (2015-12-16) in reply to comment 2 by Talha Bin Faisal Comment
Suppose you have a blog table which contains these columns (there will be more, this is just for example)
id - int, primary auto increment key title - varchar, index key blogentry - text
Then you have a comment table that will contain these columns
id - int, primary auto increment key blogid - int comment - text
The value in the blogid column will be the id for the blog entry in the blog table.
This creates the relation between a blog entry and all comments for that entry.
4. by Dave Smith - 1 year ago (2015-12-16) in reply to comment 3 by Dave Smith Comment
Not sure why, but the post lost its line spacing with the columns.
So columns for blog are id, title, blog entry.
Columns for comment are id, blogid and comment
This comments system is very complete with possibility to have replies and like buttons for each comment. It uses MySQLi so it will work well on PHP 7.
Anyway, as Dave explained you need to have a reference from the comments table to the blog posts table. Usually that reference is the ID of the post comment.
At the time of this writing, this comment system does not have that field but I am sure if you post a request in the package support forum, the author can add it easily.
1. by Superluk - 2 months ago (2016-12-15) Reply
Sorry - no recommendation - this comments system does not work properly. Thumbs up and down are not working. No support - no answers in forum