title: php while loop only executes if there is already first record in database for each userid
body: <p>I have a function which works, but not exactly as expected. This is because <code>while ($row = mysqli_fetch_assoc($result))</code> executes only if there is already one record inside a database for a specific user.</p>
  
  <p>For example when I am trying to add first comment for user with ID=1 it pushes data into database table but it is not displayed. Then if I'll try to add second comment it finally displays it and any other record added after that.</p>
  
  <p>Here is my function code.</p>
  
  <pre><code>function displayUserReviews() {
  
          global $link;
  
          $query = "SELECT * FROM user_reviews WHERE receiver_id='".$_GET['userid']."' LIMIT 10";
          $result = mysqli_query($link, $query);
          $row = mysqli_fetch_assoc($result);
  
          if (mysqli_num_rows($result) == 0) {
  
              echo "&lt;div class='alert alert-info'&gt;This user does not have any comments on his profile yet.&lt;/div&gt;";
  
          } else {
  
              $queryUser = "SELECT * FROM users WHERE id='".$row['sender_id']."'";
              $queryUserResult = mysqli_query($link, $queryUser);
  
              $rowUser = mysqli_fetch_assoc($queryUserResult);
              $userName = $rowUser['username'];
              $userId = $rowUser['id'];
  
          }
  
          while ($row = mysqli_fetch_assoc($result)) {
  
              $comment = $row['comment'];
  
              echo "&lt;div class='col' id='userReviewsDiv'&gt;&lt;em&gt;&lt;p&gt;~$comment&lt;/p&gt;&lt;/em&gt;
                      &lt;hr&gt;
                      &lt;span class='userReviews'&gt;Author: &lt;/span&gt;&lt;a href='?page=profile&amp;userid=$userId'&gt;$userName&lt;/a&gt;
                  &lt;/div&gt;";
  
          }
  
  
  
  }
  </code></pre>