title: PHP SQL While loop not working
body: <p>I have got a code that should get all of the user's Favourites from <code>favourites</code> and then it should use that information to get the info from <code>menus</code> to display them as pictures.</p>
  
  <p>All it should do is display the user's Favourites but at the moment it will only display one picture when there are many in their Favourites.</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("localhost","UN","PW","DB");
  
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $id=$_SESSION['user']['id'];
  $result = mysqli_query($con,"SELECT * FROM favourites WHERE user='$id'");
  
  while($row = mysqli_fetch_array($result)) {
      $code=$row['gamecode'];
      $con=mysqli_connect("localhost","UN","PW","DB");
      // Check connection
      if (mysqli_connect_errno()) {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
  
      $result = mysqli_query($con,"SELECT * FROM menus WHERE code='$code'");
  
      while($row = mysqli_fetch_array($result)) {
  ?&gt;
  &lt;a href="&lt;?php echo $row['link']; ?&gt;"&gt;
  &lt;img src="&lt;?php echo $row['picture']; ?&gt;" alt="&lt;?php echo $row['game']; ?&gt;"      height="120" width="150" class="fade"&gt;&lt;/a&gt;
  &lt;?php
      }
      mysqli_close($con);
  }
  
  mysqli_close($con);
  
  ?&gt;
  </code></pre>