title: Echo rows via JOIN in MySQL/PHP (?)
body: <p><a href="https://i.stack.imgur.com/IVqRT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IVqRT.png" alt="enter image description here"></a></p>
  
  <p>I wanna be able to echo out if <code>Groupname</code> and <code>Username</code>  are connected correctly, where the current <code>userid</code> (saved in a session) is <code>$uid</code>.</p>
  
  <p>I've been sitting for hours trying all kinds of JOINs and the closest I've gotten is having it output 1/? members for each team, but not all of them.</p>
  
  <p>EDIT:</p>
  
  <pre><code>$uid = $_SESSION['uid'];
  $sql = "SELECT * FROM group
          INNER JOIN usergroup ON group.groupid=usergroup.groupid
          WHERE usergroup.userid=$uid";
  $result=$mysqli-&gt;query($sql);
  
  if(mysqli_num_rows($result)&gt;0) {
      while($row = mysqli_fetch_array($result)) {
          $gid = $row['groupid'];
          $sql2 = "SELECT * FROM user
                   INNER JOIN usergroup ON user.userid=usergroup.userid
                   WHERE usergroup.groupid=$gid";
          $result2=$mysqli-&gt;query($sql2);
          $row2 = mysqli_fetch_array($result2);
  
          echo "&lt;td&gt;".$row['groupname']."&lt;/td&gt;";
          echo "&lt;td&gt;".$row2['username']."&lt;/td&gt;";
          echo "&lt;td&gt;".$row['groupid']."&lt;/td&gt;";
      }
  }
  </code></pre>
  
  <p>Thing is, that it kinda works well, except that it doesn't print all the <code>groupmembers</code> names out, it prints out just one. Which one seems to depend on the order in the table.</p>