please help me in comment reply!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    please help me in comment reply!

    i have a blog and i have a function to comment in my posts. now when i tried to reply of a comment, then my comment gone at the bottom of the comment. how to make it right after the comment on which i replied.
    my db is like this:
    Code:
    CREATE TABLE `comment` (
      `id` int(11) NOT NULL auto_increment,
      `bid` int(11) NOT NULL,
      `wid` int(11) NOT NULL,
      `uid` int(11) NOT NULL,
      `reply` int(11) NOT NULL,
      `comment` text NOT NULL,
      `time` int(11) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
    where bid means the blogid, wid means the blog writer id, uid goes with the userid who comment reply is the parameter to collect on which the reply comment, comment is the comment, time is the time of the comment.

    my php code is:
    PHP Code:
    $qints = @mysql_query("select * from `comment` where bid = '$id'");
    while (
    $commenting mysql_fetch_array($qints)) {
    $us = @mysql_fetch_array(mysql_query("select * from `user` where id='$commenting[3]'"));
    $poster htmlspecialchars_decode($us[4]);
    $time ts($commenting[6]);
    echo 
    "<ol class='commentlist'>";
    echo 
    "<li class='comment'>";
    echo 
    "<div id='comment'>";

    echo 
    "<div class='comm-top'>";//1
    echo "<div class='comment-author vcard sleft'>";
    echo 
    "<img alt='$poster' src='$us[11]' class='avatar' height='40' width='40' />";
    echo 
    "<cite class='fn'><a rel='nofollow' style='color: #339966;' href='profile.php?id=$us[0]'>$poster</a></cite> <span class='says'>$sayslang</span>";
    echo 
    "</div>";

    echo 
    "<div class='comment-meta sright'>";
    echo 
    "<a href='#'>$time</a>";
    echo 
    "</div>";
    echo 
    "</div>";//1.

    echo "<div class='comment-body'>";
    echo 
    "<p>".htmlspecialchars_decode($commenting[5])."</p>";
    echo 
    "<div class='reply'>";
    echo 
    "<a class='comment-reply-link' href='#rf=$commenting[0]'>$replylang</a>";
    echo 
    "</div>";
    echo 
    "</div>";

    echo 
    "<div class='comment-body-line'></div>";
    echo 
    "</div>";
    echo 
    "</li>";
    echo 
    "</ol>";

    now can anyone please show me what to do?

    #2
    ORDER BY id

    Comment


      #3
      Originally posted by something else View Post
      ORDER BY id
      u misunderstood my post..
      my problem is when i replied in a comment that means child comment, then the child comment was at the bottom of all comments. but i want the child comment right under neath of the main comment.

      Comment


        #4
        you have 2 choices with ORDER ... ORDER BY id ASC (same as ORDER BY id) which is default or ORDER BY id DESC which is the way you dont want it?

        Unless you mean sub commenting Eg:
        Code:
        this is some blog blah blah blah.
        
        Peter comments: WOW reaally good.
        sub reply
        
        John comments: bad
        sub reply
               sub comment ->    peter comments: @John: what do you mean bad? ->sub reply
               sub comment ->    John comments: @peter: it sucks ->sub reply
        
        paul comments: blah
        sub reply
        
        
        Main Reply HERE

        Comment


          #5
          yes i mean that sub commenting. when i commented of a comment, it goes at the end of all the comment. thats been my problem.

          Comment


            #6
            PHP Code:
            REATE TABLE `comment` (
              `
            idint(11NOT NULL auto_increment,
              `
            bidint(11NOT NULL,
              `
            widint(11NOT NULL,
              `
            uidint(11NOT NULL,
              `
            replyint(11NOT NULL,
              `
            commenttext NOT NULL,
              `
            timeint(11NOT NULL,
              `
            subcommentint(11NOT NULL,
              `
            hasubcommentint(1) DEFAULT 0,
              
            PRIMARY KEY  (`id`)
            ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=;




            $qints = @mysql_query("select * from `comment` where bid = '$id'"); 
            while (
            $commenting mysql_fetch_array($qints)) { 
            $us = @mysql_fetch_array(mysql_query("select * from `user` where id='$commenting[3]'")); 
            $poster htmlspecialchars_decode($us[4]); 
            $time ts($commenting[6]); 
            echo 
            "<ol class='commentlist'>"
            echo 
            "<li class='comment'>"
            echo 
            "<div id='comment'>"

            echo 
            "<div class='comm-top'>";//1 
            echo "<div class='comment-author vcard sleft'>"
            echo 
            "<img alt='$poster' src='$us[11]' class='avatar' height='40' width='40' />"
            echo 
            "<cite class='fn'><a rel='nofollow' style='color: #339966;' href='profile.php?id=$us[0]'>$poster</a></cite> <span class='says'>$sayslang</span>"
            echo 
            "</div>"

            echo 
            "<div class='comment-meta sright'>"
            echo 
            "<a href='#'>$time</a>"
            echo 
            "</div>"
            echo 
            "</div>";//1. 
            if($commenting['hassubcomment']==1)
            {
            $qintsx = @mysql_query("select * from `comment` where subcomment = '".$commenting['id']."'"); 
            while (
            $commentingx mysql_fetch_array($qintsx)) { 
            $usx = @mysql_fetch_array(mysql_query("select * from `user` where id='$commenting[3]'")); 
            $posterx htmlspecialchars_decode($usx[4]); 
            $timex ts($commentingx[6]); 
            echo 
            "<ol class='commentlist'>"
            echo 
            "<li class='comment'>"
            echo 
            "<div id='comment'>"

            echo 
            "<div class='comm-top'>";//1 
            echo "<div class='comment-author vcard sleft'>"
            echo 
            "<img alt='$posterx' src='$usx[11]' class='avatar' height='40' width='40' />"
            echo 
            "<cite class='fn'><a rel='nofollow' style='color: #339966;' href='profile.php?id=$usx[0]'>$posterx</a></cite> <span class='says'>$sayslang</span>"
            echo 
            "</div>"

            echo 
            "<div class='comment-meta sright'>"
            echo 
            "<a href='#'>$timex</a>"
            echo 
            "</div>"
            echo 
            "</div>";//1. 

            echo "<div class='comment-body'>"
            echo 
            "<p>".htmlspecialchars_decode($commentingx[5])."</p>"
            echo 
            "<div class='reply'>"
            echo 
            "<a class='comment-reply-link' href='#rf=$commentingx[0]'>$replylang</a>"
            echo 
            "</div>"
            echo 
            "</div>"

            echo 
            "<div class='comment-body-line'></div>"
            echo 
            "</div>"
            echo 
            "</li>"
            echo 
            "</ol>";

            }
            echo 
            "<div class='comment-body'>"
            echo 
            "<p>".htmlspecialchars_decode($commenting[5])."</p>"
            echo 
            "<div class='reply'>"
            echo 
            "<a class='comment-reply-link' href='#rf=$commenting[0]'>$replylang</a>"
            echo 
            "</div>"
            echo 
            "</div>"

            echo 
            "<div class='comment-body-line'></div>"
            echo 
            "</div>"
            echo 
            "</li>"
            echo 
            "</ol>"

            then when adding sub comment insert the id of the comment into subcomment and set hassubcomment to 1 (this is to prevent unnecessary calls to database)

            Comment


              #7
              now i am using this:
              Code:
              $qints = @mysql_query("select * from `comment` where bid = '$id'");  
              while ($commenting = mysql_fetch_array($qints)) {  
              $us = @mysql_fetch_array(mysql_query("select * from `user` where id='$commenting[3]'"));  
              $poster = htmlspecialchars_decode($us[4]);  
              $time = ts($commenting[6]);  
              echo "<ol class='commentlist'>";  
              echo "<li class='comment'>";  
              echo "<div id='comment'>";  
              
              echo "<div class='comm-top'>";//1  
              echo "<div class='comment-author vcard sleft'>";  
              echo "<img alt='$poster' src='$us[11]' class='avatar' height='40' width='40' />";  
              echo "<cite class='fn'><a rel='nofollow' style='color: #339966;' href='profile.php?id=$us[0]'>$poster</a></cite> <span class='says'>$sayslang</span>";  
              echo "</div>";  
              
              echo "<div class='comment-meta sright'>";  
              echo "<a href='#'>$time</a>";  
              echo "</div>";  
              echo "</div>";//1.
              echo "<div class='comment-body'>";  
              echo "<p>".htmlspecialchars_decode($commenting[5])."</p>";  
              echo "<div class='reply'>";  
              echo "<a class='comment-reply-link' href='#rf=$commenting[0]'>$replylang</a>";  
              echo "</div>";  
              echo "</div>";  
              
              echo "<div class='comment-body-line'></div>";  
              echo "</div>";  
              if($commenting[8]==1) 
              { 
              $qintsx = @mysql_query("select * from `comment` where subcomment = '".$commenting['id']."'");  
              while ($commentingx = mysql_fetch_array($qintsx)) {  
              $usx = @mysql_fetch_array(mysql_query("select * from `user` where id='$commenting[3]'"));  
              $posterx = htmlspecialchars_decode($usx[4]);  
              $timex = ts($commentingx[6]);  
              echo "<ul class='childen>";
              echo "<li class='comment'>";  
              echo "<div id='comment'>";
              echo "<div class='comm-top'>";//1  
              echo "<div class='comment-author vcard sleft'>"; 
              echo "<img alt='$posterx' src='$usx[11]' class='avatar' height='40' width='40' />";  
              echo "<cite class='fn'><a rel='nofollow' style='color: #339966;' href='profile.php?id=$usx[0]'>$posterx</a></cite> <span class='says'>$sayslang</span>";  
              echo "</div>";
              echo "<div class='comment-meta sright'>";  
              echo "<a href='#'>$timex</a>";  
              echo "</div>";  
              echo "</div>";//1.  
              echo "<div class='comment-body'>";  
              echo "<p>".htmlspecialchars_decode($commentingx[5])."</p>";  
              echo "<div class='reply'>";  
              echo "<a class='comment-reply-link' href='#rf=$commentingx[0]'>$replylang</a>";  
              echo "</div>";
              echo "</div>";
              echo "<div class='comment-body-line'></div>";
              echo "</div>";
              echo "</li>";
              echo "</ul>";
              }
              }  
              echo "</li>";  
              echo "</ol>";  
              }
              but seems its not showing the image of the sub comment, also showing the sub comment in the bottom of the all main comment.

              Comment


                #8
                make sure you dont insert the bid but just the comment id into subcomment

                As for the image ... it looks to be image of a user all i have done is copied your original querys and assigned them to a new variable name (same as other 1s just with x on the end)
                so i have no idea what $usx[11] is :P

                Comment

                Working...
                X