title: How to make mysql generated posts to be independent onn their own
body: <p>i am retrieving posts from a table called post . I wanted to add a commenting feature to this code, The problem is that the latest posts variables are dominant over others in that if you comment on an older post, the variables of the "<strong>latest post(which appears first because of the ORDER BY ID DECS criteria"</strong> 
   Someone help me make this posts independent on their own...Thanks </p>
  
  <pre><code> &lt;?php
  
      $sqlhash="SELECT * FROM posts ORDER BY id DESC ";
          $result_hash = mysqli_query($conn,$sqlhash);
          while($rowhash = mysqli_fetch_assoc( $result_hash))
          {
              $user = $rowhash['user'];
              $message = $rowhash['post'];
              $time =  $rowhash['time'];
          $id=  $rowhash['id'];
              $tt = date('m/d/Y H:i:s',$time);
  
      $my_id = $_SESSION['user_id'];
  
  
  
  
       $sql="SELECT * FROM users WHERE Full_name='$user'  ";
        $result_set = mysqli_query($conn,$sql);
        while($row = mysqli_fetch_assoc( $result_set))
        {
  
          $select_username = $row['Full_name'];
          $profp = $row['pic'];
  
  
  
      $my_id = $_SESSION['user_id'];
  
  
      ?&gt;
  
  &lt;center&gt;&lt;div class='post' style='width:48%; height:40%; align:middle; text-align:left; margin:30px 0'&gt;
  &lt;img width="70" height="70" src='uploads/&lt;?php echo $profp; ?&gt;'&gt;&lt;br&gt;&lt;p style='color:#0c88b5'&gt;&lt;b&gt;  &lt;?php echo $id ;?&gt;&lt;br&gt;&lt;?php echo $user ;?&gt;On:&lt;?php echo $tt ; ?&gt;&lt;h4&gt;&lt;b&gt;&lt;?php echo $message 
  ;?&gt;&lt;/h4&gt;&lt;/p&gt;&lt;hr&gt;
  &lt;?php 
  
  $sqlcom="SELECT * FROM comment WHERE hash='$id' ";
      $result_com = mysqli_query($conn,$sqlcom);
      while($rowcom = mysqli_fetch_assoc( $result_com))
      {
          $usercom = $rowcom['comment'];
          $comenter = $rowcom['user'];
  
  echo "&lt;p style='color:#0c88b5' $comenter&lt;/p&gt;". ":" ;
   echo $usercom. "&lt;br&gt;" ;
  
   }
  if (isset($_POST['commen'])) {
  
  
  $sqlhash= "SELECT * FROM posts WHERE post= '$message' ";
      $result_hash = mysqli_query($conn,$sqlhash);
      while($rowhash = mysqli_fetch_assoc( $result_hash))
      {
          $user1 = $_SESSION['username'];
          $comment = $_POST['commen'];
          $time =  $rowhash['time'];
  
  
  
          $time2 = $_SESSION['time'];
  
  
  
   $sql3 = "INSERT INTO comment (user, comment, hash) VALUES
               ('$user1','$comment', '$id')";
  
               if($conn-&gt;query($sql3) === TRUE) {
  
  header('Location: timeline.php');
  
  }else {
      echo"error";
  }
  </code></pre>