Jump to content

Commenting system


Recommended Posts

I have created a site that has a lot of videos and at first where my videos live in the database I put a comments field. I realized though that that will not work since there will be more than 1 user putting a comment on a video.


How should I go about doing this? Ive made a comments table, but am unsure on what fields I need. Should each video have a table with comment? I dont see that as a practical solution since there will be about a 1000 tables then :-/ any suggestions?

Link to comment
Share on other sites

You only need 1 comments table. This will have the comment id, user id, video id, comment, and whatever else you want like date left or status


CREATE TABLE `comments` (
  `cid` int(11) NOT NULL auto_increment,
  `userid` int(11) NOT NULL default '0',
  `videoid` int(11) NOT NULL default '0',
  `message` text NOT NULL,
  `status` smallint(1) NOT NULL default '0',
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`cid`)

Link to comment
Share on other sites

It's something I use for the "owner" of the video/picture/whatever. If status is set to 0 then the owner didn't view it yet. Once they view the comment(s) then this is set to 1. It's up to you if you use this or not. If you don't you can just take it out of the query.

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.

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.