TheFilmGod Posted July 21, 2007 Share Posted July 21, 2007 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 https://forums.phpfreaks.com/topic/61127-solved-write-a-comment-mysql/ Share on other sites More sharing options...
L Posted July 21, 2007 Share Posted July 21, 2007 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 https://forums.phpfreaks.com/topic/61127-solved-write-a-comment-mysql/#findComment-304192 Share on other sites More sharing options...
Mutley Posted July 21, 2007 Share Posted July 21, 2007 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. 2 tables seems sufficient. (I would avoid a table for each page). Link to comment https://forums.phpfreaks.com/topic/61127-solved-write-a-comment-mysql/#findComment-304194 Share on other sites More sharing options...
TheFilmGod Posted July 21, 2007 Author Share Posted July 21, 2007 Thank you for your help. This now makes a lot of sense. I guess my way would be too complicated! Thanks! Link to comment https://forums.phpfreaks.com/topic/61127-solved-write-a-comment-mysql/#findComment-304202 Share on other sites More sharing options...
AndyB Posted July 21, 2007 Share Posted July 21, 2007 http://www.digitalmidget.com/php_noob/comment.php Mine might give you some ideas. Link to comment https://forums.phpfreaks.com/topic/61127-solved-write-a-comment-mysql/#findComment-304220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.