发布回复无法从第二篇文章开始工作

时间:2014-11-22 07:46:21

标签: javascript php mysqli

我正在为我的网站发布评论发布系统。一切都运作良好。但是在每个评论的回复的情况下,回复工作完全为最后/新提交的评论。

当我去回复时,其他人评论它提交的名称并显示它但不能提交表格的文本区域。

*(1)如果我在页面末尾替换我的回复表格并用css进行测试然后回复工作,但回复按钮不能在下面滑动以显示每条评论的回复表格。

*(2)如果我在回复评论后更换我的回复,则回复第1条评论的工作。

在post.php中显示如下

所以我认为我的问题出在我的post.php页面中,以便在我的回复表格或其他任何内容中替换。

这是我的post.php

    <script type='text/javascript'>
        $(function(){
            $("a.reply").click(function() {
                var id = $(this).attr("id");
                $("#parent_id").attr("value", id);
            });
        });
    </script>

    <script>
        //showReplyBox
        $('a.reply').livequery("click", function(e){
            var getpID =  $(this).attr('id').replace('','');    
            //$('.commentBox').hide();
            $("#reply_here-"+getpID).show();
        });
    </script>
</head>

<?php
    include("db.php");
    function submitComments($tutid2){
        //This is submit main post form.
    }
?>

<?
    function getComments($tutid){
    global $dbh;
    //fetch all comments from database where the qazi_id number is the one you are asking for
    $results = mysqli_query($dbh,"SELECT * FROM comments_lite WHERE qazi_id='$tutid' ORDER BY id DESC LIMIT 5") or die(mysqli_error($dbh));

    echo'<div class="comments"><div id="updates"><div class="content"><comment>';

    // Show only main comment

    while($row = mysqli_fetch_array($results)) 
    {   $id = $row['id'];
        $qazi_id = $row['qazi_id'];
        $likes = $row['likes'];
        $username = $row['username'];
        $img = $row['img'];
        $description = $row['description'];     
        $url = $row['url'];
        $parent_id = $row['parent_id'];
        $date = $row['date'];

        echo'<div class="comment">
                <div class="cdomment_cheder">';
        echo'<p class="name"><a href="userinfo.php?user='.$url.'"  title="'.$username.'">'.$username.'</a> Says:</p>';
        echo'<span class="cdomment_time">'.$date.'</span><br/>
            <div class="avatarcnt">
                <img alt="" src="uploadprofile/'.$u_imgurl.'"/>
            </div></div></div>
            <div class="cdomment_text">';
            if ($description=="") {echo '';}
            else echo''.htmlentities($description).'<br>';
            if ($img=="") {echo '';}
            else echo'<br><img src="comimage/'.$img.'"/>';
            echo '</div>';

    //delete
    echo'<div class="delete" align="right"><a href="delete.php?id='.$id.'">Delete</a></div>';

    //reply
    echo'<div class="reply_box"><a href="javascript: void(0)" class="reply" id="'.$id.'">Reply</a></div>';

   //Likes
    echo''; 

   //Reply form

    echo'<div id="loader"></div><div class="reply_here" id="reply_here-'.$id.'" style="display:none;">
            <form action="" method="post" id="repfrm" enctype="multipart/form-data">
                <fieldset id="cmntfs">
                    <legend class="pyct">Your comment</legend>
                    <input type="hidden" name="username" tabindex="1" id="author" value="'.$username.'"/>
                    <input type="hidden" name="url" tabindex="2" id="url" value="" />
                    <div id="maintbox">
                        <textarea name="replycom" rows="2" tabindex="4" id="replycom" value=""></textarea>
                    </div>
                    <input type="hidden" name="parent_id" id="parent_id" value="0" />
                    <input type="hidden" name="tutid2" id="tutid" value="'.$tutid2.'" />
                    <button type="submit" name="submit" value="" tabindex="5" id="submit" class="repfrm">Post Reply</button>
                </fieldset>
            </form>
        </div>';

    // Show Reply of each comment
    $query = "SELECT * FROM comments_reply WHERE parent_id ='".$id."'";
    $res = mysqli_query($dbh,$query);
    while($row = mysqli_fetch_array($res)) 
    {   $id = $row['id'];
        $qazi_id = $row['qazi_id'];
        $likes = $row['likes'];
        $username = $row['username'];
        $img = $row['img'];
        $description = $row['description'];     
        $url = $row['url'];
        $parent_id = $row['parent_id'];
        $date = $row['date'];

            echo' <div class="rcontent"><replycomment><ul>
                <div class="comment">
                <div class="cdomment_cheder">';
                if ($url=="") {
                    echo'<p class="name">'.$username.' Says:</p>'; }
                else  echo'<p class="name"><a href="userinfo.php?user='.$url.'" title="'.$username.'">'.$username.'</a> Says:</p>';
                echo'<span class="cdomment_time">'.$date.'</span><br/>
                    <div class="avatarcnt">
                        <img alt="" src="uploadprofile/'.$u_imgurl.'"/>
                    </div></div></div>
                    <div class="cdomment_text">';
                        if ($description=="") {echo '';}
                        else echo''.htmlentities($description).'<br>';
                        if ($img=="") {echo '';}
                        else echo'<br><img src="comimage/'.$img.'"/>';
                echo '</div>';
                //delete        
                echo'<div class="delete" align="right"><a href="deletereply.php? id='.$id.'">Delete</a></div>';

                echo'</ul><replycomment></div>';

            }   //reply while close 

            *(2) And if i replace my reply from here then reply work for 1st comment.    

        }   //comment while close

        *(1) If i replace my reply form here and visible with css for test then reply work but reply button cannot slide below to show reply form for each comment.

        echo'</div><comment></div>';

    } //fuction close
?>

0 个答案:

没有答案