mysql评论功能

时间:2013-02-26 18:49:48

标签: php mysql comments

我想在每个帖子中建立评论系统。我使用一些查询加载帖子然后我有我的HTML代码为用户写评论。但是当用户点击进入时,评论会转到我在墙上的所有帖子,因为我在一段时间内有评论查询,而这一段时间用于帖子我可以做什么,所以每个新评论只发布它必须的帖子?

$comment_text = $_POST["comment_text_$post_id"];
       $comment_to = $_POST['comment_to'];
       $posted_by = $_POST['post_by'];
       $o = "_posts_comments";

       if (isset($comment_text)){
                $ctime = time();
         $add_comment = mysql_query("INSERT INTO uid_$posted_by$o VALUES('','$comment_text','$my_id','$ctime','$comment_to')");
         header("Location: http://localhost/thelinkedbox/");
       }

然后在帖子的while循环中评论sumbit表单

                      echo "<form action='' method='POST'><p></p>
                          <center><img src='./img/comment_up_arrow.png' style='margin: -10px 0 0 ;'></center><br />
                          <p><div style='width:448px;background:#E6E6E6;border-bottom:1px solid #BDBDBD;padding:5px;border-radius:3px;margin: -40px 0 0;' class='comm_style'>
                          ";

                         if ($commenter_avatar == 0) {
                          echo "<a href='http://localhost/thelinkedbox/profile.php?i=$commenter'><img src='./img/no_image.jpg' title='$commenter_f_name $commenter_l_name' width='30px' style='border-radius:4px;height:30px;'></a> <input name='comment_text' placeholder='add a comment' class='search-query' style='margin: 1px 0 0;width:405px;' type='text'>";
                         }else{
                          echo "<a href='http://localhost/thelinkedbox/profile.php?i=$commenter'><img src='./images/$commenter_avatar' title='$commenter_f_name $comenter_l_name' width='30px' style='border-radius:4px;height:30px;'></a> <input name='comment_text' placeholder='add a comment' class='search-query' style='margin: 1px 0 0;width:405px;' type='text'>";
                         }



                        echo "
                        <input type='hidden' value='$post_id' name='comment_to'>
                        <input type='hidden' value='$from_uid' name='post_by'>
                        </div></p></form>

                          ";

0 个答案:

没有答案