Jump to content

comments not displaying to appropriate posts in my feed


shan
 Share

Recommended Posts

hi, guys after taking jacques1 advice on having a relational scheme for my db to fetch results for my project, i was finally able to produce results for the users timeline, but now the problem arises with the feeds page where i'm not able to make the comments to display to its appropriate posts. cant figure out where the bug is arising. if you can help me it would be much appreciated. other than the comments problem there seems to be no errors displaying on the page.i'll attach a DB schema here for you all to look in to.

vvCDn.png

 

here is the code:

<?php
  
    
    
    
    $statusui_edit="";
       $status2view=$project->statusView($_SESSION['uname']);
   foreach($status2view as $row){
      $status_replies="";
$updateid=$row['update_id'];
                $account_name=$row['account_name'];
                $os_id=$row['os_id'];
                $author=$row['author'];
                $post_date=$row['time'];
                $title= stripslashes($row['title']);
                $data= stripslashes($row['update_body']);
               
                $statusdeletebutton='';
           
       
        $sql1="select * from updates,comment_update where comment_update.os_id like updates.update_id and comment_update.type like 'b'";
       $sql2="select * from updates left join comment_update on comment_update.os_id = updates.update_id where updates.update_id=:statusid";
        $stmth=$conn->prepare($sql2);
       // $stmth->bindparam(":either",$_SESSION['uname']);
        $stmth->bindparam(":statusid",$updateid);
        $stmth->execute();
        $status_reply= $stmth->fetchAll(PDO::FETCH_ASSOC);
   

         foreach  ($status_reply as $row1) {
           
         
         $status_reply_id=$row1['comment_id'];
        
                $reply_author=$row1['author'];
                $reply_d=htmlentities($row1['comment_body']);
                $reply_data=  stripslashes($reply_d);
                $reply_osid=$row1['os_id'];
                $reply_date=$row1['time'];
                $reply_delete_button="";
               if ($reply_author==$_SESSION['uname'] ) {
                   $reply_delete_button.="<li><span id='$status_reply_id' class='delete_reply_btn glyphicon glyphicon-remove'><a href='#' title='Delete this comment'>Remove X</a></span></li>";
               }
                if ($sql2==TRUE) {  
              $status_replies.="<div  class='replyboxes pull-left reply_".$status_reply_id."'>Reply by:-<a href='home.php?u=".$reply_author."'>".$reply_author."</a>"
                      . "<span class='pull-right'>".$reply_date 
                       . "<b class='caret'>
                         <small><span class='btn-xs btn-danger dropdown-toggle pull-right' data-toggle='dropdown' aria-expanded='true' ><span class='glyphicon glyphicon-edit'></span>
                        <ul class='dropdown-menu'>".$reply_delete_button
                      . "<li><a href='#' class='hidden_text_area glyphicon glyphicon-pencil reply_".$status_reply_id."' title='Edit this comment' >Edit</a></li>"
                      . "<li><a href='report.php?u='".$reply_author."'>Report</a><li></ul>"
                      . "</span></span></small></b><br><legend>".  html_entity_decode($reply_data)."</legend><br></div>";
              }  else {
                    $status_replies.="";
               }
   }
   
              
       
                //insert_status_ui script to get message.
                if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) {
                $statusdeletebutton='<li>'
                           . '<a href="#" type="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>';
                $edit_btn='<li>'
                        . '<a href="#" attr="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>';
                
                }
               
                    
                
                $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.'  jumbotron">'
                        . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">'
                        . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>'
                        . '<span class="pull-right">'
                        . '<div class="dropdown">'
                        . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"  >'
                        . '<span class="glyphicon glyphicon-edit"></span></button>'
                        . '<ul class="dropdown-menu">'
                        .$edit_btn.'<br>'. $statusdeletebutton.'</ul></div></span><br><hr>'
                        . '<legend><span class=" data_s_2copy" type="'.$updateid.'" >'
                        . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:-  <a href="home.php?u='.$author.'">'.$author.   '</a>   '.$post_date.'</small></b>'
                        . '<br><p>'.$status_replies.'</p><br>';

                    $status_list.= '<textarea id="reply_textarea_'.$updateid.'"  class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>'
                            . '<button id="reply_btn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply_'.$updateid.'">Reply</button></div>';
             
     
   $friends = array();
        // select friend_one, friend_two from friends where (friend_one = 1 or friend_two =1) and accepted = 1
	$stmt=  $conn->prepare("select friend_one from friends where friend_two=:session and accepted='1'");
            $stmt->bindparam(":session",$_SESSION['uname']);
            $stmt->execute();
            foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $r) {
    array_push($friends, $r["friend_one"]); 
   
}
            $stmth1=  $conn->prepare("select friend_two from friends where friend_one=:session and accepted='1'");
            $stmth1->bindparam(":session",$_SESSION['uname']);
            $stmth1->execute();
            foreach ($stmth1->fetchAll(PDO::FETCH_ASSOC) as $r1) {
    array_push($friends, $r1["friend_two"]); 
   for($i = 0; $i < count($friends); $i++){
		$friend = $friends[$i];
   $sql1="select* from updates where account_name=:friend and type='a' or account_name=:friend and type='c' order by time desc";
   $stmt=$conn->prepare($sql1);
   $stmt->bindValue(":friend",$friend);
   $stmt->execute();
   $feeds=$stmt->fetchAll(PDO::FETCH_ASSOC);             
   foreach ($feeds as $val) {
                $updateid=$val['update_id'];
                $account_name=$val['account_name'];
                $os_id=$val['os_id'];
                $author=$val['author'];
                $post_date=$val['time'];
                $title= stripslashes($val['title']);
                $data= stripslashes($val['update_body']);
                $statusdeletebutton='';
                if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) {
                $statusdeletebutton='<li>'
                           . '<a href="#" type="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>';
                }
               
                    
                
                $status_list.= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.'  jumbotron">'
                        . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">'
                        . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>'
                        . '<span class="pull-right">'
                        . '<div class="dropdown">'
                        . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"  >'
                        . '<span class="glyphicon glyphicon-edit"></span></button>'
                        . '<ul class="dropdown-menu">'
                        . '<li><a href="#" attr="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr>'
                        . '<legend><span class=" data_s_2copy" type="'.$updateid.'" >'
                        . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:-  <a href="home.php?u='.$author.'">'.$author.   '</a>   '.$post_date.'</small></b>'
                        . '<br><p>'.$status_replies.'</p><br>';

                    $status_list.= '<textarea id="reply_textarea_'.$updateid.'"  class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>'
                            . '<button id="reply_btn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply_'.$updateid.'">Reply</button></div>';
               
     
}              
            }
            
   }
   
     
                   
                      
                echo $status_list;
                 
                
                }
   
                
     
               
      ?>
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.