title: Displaying Friend Requests
body: <p>I have been working on making a social-network similar to facebook to use on my home server. However, i have come across a problem with displaying friend requests in the notifications tab of the user profile.</p>
  
  <pre><code>&lt;?php
      //Check for notifications script
      $Request = "Requests";
      $Pending = "Pending";
      $nCheck = mysqli_query($Connect,"SELECT * FROM friends WHERE rTo = '$Uname' AND Status = '$Pending'");
      $nNum = mysqli_num_rows($nCheck);
      if($nNum != 0){
          if($nNum === 1){
              $Request = "Request";
          }
          else
          {
              $Request = "Requests";
          }
          echo"&lt;p style=\"font-family: Tahoma; margin-left: 20px;\"&gt;You Have &lt;b&gt;$nNum&lt;/b&gt; Friend $Request&lt;/p&gt;&lt;hr /&gt;";
          while($row = mysqli_fetch_assoc($nCheck)){
              $dbFrom = $row['rFrom'];
              $dbId = $row['id'];
              $dbStatus = $row['Status'];
              for($i = 0; $i &lt; 1; $i++){
                  echo"&lt;p style=\"font-family: Tahoma; margin-left: 20px;\"&gt;$dbFrom wants to be your friend &lt;form action=\"\" method=\"POST\"&gt;&lt;input type=\"submit\" name=\"A\" value=\"Accept\"&gt;&lt;/form&gt; &lt;form action=\"\" method=\"POST\"&gt;&lt;input type=\"submit\" name=\"D\" value=\"Decline\"&gt;&lt;/form&gt;&lt;/p&gt;";
              }
          }
      }
      else
      {
          echo "&lt;p style=\"font-family: Tahoma; margin-left: 20px;\"&gt;You Have &lt;b&gt;0&lt;/b&gt; Friend $Request&lt;/p&gt;";
      }
      ?&gt;
  </code></pre>
  
  <p>And then this is the form for the Accept / Decline:</p>
  
  <pre><code>&lt;?php
      //Accept/Decline Friend Request Script
      $Accepted = @$_POST['A'];
      $Declined = @$_POST['D'];
      $A = "Accepted";
      $D = "Declined";
      if($Accepted){
          $addFriend = mysqli_query($Connect,"UPDATE friends SET Status = '$A' WHERE rTo = '$Uname' AND rFrom = '$dbFrom'");
          header("Location: Notification.php");
      }
      else if($Declined){
          $addFriend = mysqli_query($Connect,"UPDATE friends SET Status = '$D' WHERE rTo = '$Uname' AND rFrom = '$dbFrom'");
          header("Location: Notification.php");
      }
      ?&gt;
  </code></pre>
  
  <p>The problem is that if more than one notification is present, the last notification will be the one that is accepted or declined. Please help, much appreciated.</p>