如何显示每个帖子的所有评论(文章,视频等.....)php Jquery

时间:2017-06-13 19:15:38

标签: javascript php jquery ajax session

我正在尝试使用php jquery ajax构建评论系统,但在创建评论系统时遇到一些麻烦所有评论都显示为所有文章 请让我知道

的index.php

 $post_id=mysqli_fetch_array(mysqli_query($connection,"SELECT MAX(qid) FROM 
`queries` WHERE uid='".$_SESSION['id']."'"));

 $result = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM 
 queries where  qid='".$post_id[0]."'"));

   <span style="font-weight:bold;color:#494949;font-family: Arial,Helvetica,sans-serif;font-size:12px;line-height:20px">




                <p>
                <?php  if(getuserPhoto($result['uid'])=='')
                { ?>
                <img width="45px" height="45px" style="margin-top: 1px; float:left;border: 1px solid #ddd;
border-radius: 2px;    padding:2px;" src="img/posted_by.png">
                <?php }
                else
                { ?>
                        <img width="45px" height="45px"style="margin-top:1px; float:left;border: 1px solid #ddd;
border-radius: 2px;    padding:2px;"src="/cropphoto/upload_images/<?php echo getuserPhoto($result['uid']); ?>">  
                <?php }
                ?>


            <a style="text-decoration: none;padding:8px; text-transform: capitalize;font-weight:bold;" href="/<?php echo 
getSlug($getrows['uid']);?>"><?php echo getName($result['uid']);?></a> 

                                  <p style="font-size:14px; color:#BFBFBF;   margin-left:53px;">
                Posted on:<?php echo $result['submitted_on'];?></p>

                <td data-title="Asked Query"><span style="font-size:20px";><?php echo $result['title'];?></span><br>
                        <span style="color: #6c6c6c;font-family: Arial,Helvetica,sans-serif;font-size:15px;line-height:20px"><?php echo $result['query'];?></span><br>

jquery的

  $(document).ready(function()
{
 $("#comq").click(function() {

     var comment=$("#comment").val();
        $.ajax({
            cache:false,
            type:"post",
            url:"postandget.php",
            data:{comments:comment},
            success:function(data)
            {
                $('.cmt').html(data);
            }



        })

     });

    });     

postandget.php

<?php

    if(isset($_POST["comments"])){

      $comment=$_POST['comments'];



{
      $reslt_user= mysqli_query($connection,"SELECT * FROM 
 tbl_users,`queries` where id='".$_SESSION['id']."' AND  qid= '".$qid."'");

 $row_lat_lng= mysqli_fetch_array($reslt_user);

 $stmt = mysqli_query($connection,"INSERT INTO comments set 
  uid='".$_SESSION['id']."',comments='".$comment."',reply='".$reply."' ,
 qid= '".$qid."' ");

 }






  }
    <?php While(  $row= mysqli_fetch_array($com_results))  { ?>
    <div class="allcom" id="allcom">

                        <img width="45px" height="45px" src="/cropphoto/upload_images/<?php echo $row['thumbnail']; ?>">  






         <a style="text-decoration: none;padding:2px; " href="/<?php echo getSlug($row['uid']);?>"><?php echo ucfirst($row['name']);  ?></a>



                     <?php echo $row["comment_dt"]."<br> " ; ?>






           <p class="comm"><?php  echo $row["comments"]."<br>" ; ?></p><br>
               <input type="button" Name="reply" class="butn2" value="Reply"><br><br> 
               </div><br>




             <?php


   }
   ?>

请帮助我任何人提前致谢

0 个答案:

没有答案