doumei1203 2011-01-13 00:59
浏览 39
已采纳

用户评论:评论的实施 - 使用什么技术?

I have set up a company intranet website built with PHP/MySQL and allow users to post reviews. After joining up on this website I have grown to like the "comment" function and would like to add that same functionality to allow users to "comment" directly to other users reviews.

Currently all reviews are stored in a single table in the DB.

1) Should I create another table to then store all the comments since there can be many comments per review?

2) Once I figure out where to store these values can the rest of this functionality be built out in PHP or will other programming need to also be introduced?

  • 写回答

2条回答 默认 最新

  • dongpan1365 2011-01-13 01:08
    关注

    Yes and yes.

    Comments should be a seperate table, because they're comments, not reviews. They are two different things, therefore, they should not go in the same table.

    Once you've created that table with the appropriate references to other tables, it's just a matter of constructing a query which pulls out all of the information you need (e.g. SELECT user.user_name, comment.comment_text, comment.post_time FROM comment, user WHERE comment.user_id=user.user_id AND comment.review_id = 123, where 123 is the ID of the review you're getting comments for).

    The exact layout for your comment table will depend on your specific needs, but as a minimum, you'll want to know which review it's a comment for, who posted it, when they posted it, and what they actually posted.

    To insert comments, create a form on the page that displays the individual review, and when filled in, create an INSERT query which inserts into your comment table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图