Jump to content

[SOLVED] Write a Comment Mysql


TheFilmGod

Recommended Posts

So we all seen it - write a comment feature in news stories. Now how do I program that in mysql? The structure...???

 

One possibility is to have a table for everypage and each new entry would be a comment corresponding to that comment. Is there a better way to do this? Without creating too many tables?

 

I was thinking on the lines of having a huge table with all the comments and have comments with there IDs and have them bring up the appropriate comment by the id. Is that a good idea?

Link to comment
Share on other sites

well the way i have it is that i have two tables..a news and comments table...each news article is assigned an auto incremented number for an id. Then when u post a comment on an article(which now has its own id) a column called newsid is then inserted with the id of the article...so then when displaying the comments for the article do SELECT * FROM comments WHERE newid=$id. $id would be a GET from the url...

Link to comment
Share on other sites

I would do it something like this:

 

table news_stories:

id | page_id | author_id | title | story

 

table news_comments:

id | news_id | author_id | comment

 

So a page could be in the URL:

news.php?page=1

news.php?page=2

...etc

 

Then $_GET['page'] sets up the query to select the news articles on that page and for comments you would do select all the comments where the news_id = id (the news article id)

 

Just brief but I hope that makes sense. :P 2 tables seems sufficient. (I would avoid a table for each page).

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.